Sha256: b41077c5df3ddf040ba7362b84273b50fa00082ba9ec57ac2c0e864d3bdcd3be

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
require 'type_constraints/meta'

describe TypeConstraints::Meta do
  describe "#initialize" do
    context "Create new instance" do
      meta = TypeConstraints::Meta.new(name: :AlwaysTrue, constraint: -> v { true })
      it "returns TypeConstraints::Meta Object" do
        expect(meta.class).to eq TypeConstraints::Meta
      end
    end
  end

  describe "#check?" do
    context "Without parent Object." do
      meta = TypeConstraints::Meta.new(name: :AlwaysTrue, constraint: -> v { true })
      it "returns TrueClass Object" do
        result = meta.check?("hogehoge")
        expect(result).to eq true
      end
    end

    context "With parent Object" do
      parent = TypeConstraints::Meta.new(name: :AlwaysTrue, constraint: -> v { false })
      meta   = TypeConstraints::Meta.new(
        name: :AlwaysTrue,
        constraint: -> v { true },
        parent: parent
      )

      it "returns TrueClass Object" do
        result = meta.check?("hogehoge")
        expect(result).to eq false
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
type_constraints-0.1.0 spec/type_constraints/meta_spec.rb
type_constraints-0.0.1 spec/type_constraints/meta_spec.rb