Sha256: 080bdfc1cb27c67806a2b9b3a2cfbf94932de188e5c64ddd6a12e1b06381757e

Contents?: true

Size: 826 Bytes

Versions: 10

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'
module Myrrha
  describe "Coercions#belongs_to?" do
    let(:rules){ Coercions.new }

    before(:all) do
      class Coercions
        public :belongs_to?
      end
    end

    specify "with a class" do
      rules.belongs_to?(12, Integer).should be_true
    end

    specify "with a superclass" do
      rules.belongs_to?(12, Numeric).should be_true
    end

    specify "with a proc or arity 1" do
      rules.belongs_to?(12, lambda{|x| x>10}).should be_true
      rules.belongs_to?(12, lambda{|x| x<10}).should be_false
    end

    specify "with a proc or arity 2" do
      got = nil
      l = lambda{|x,t| got = t; t == l }
      rules.belongs_to?(12, l).should be_true
      got.should eq(l)
      rules.belongs_to?(12, l, :nosuch).should be_false
      got.should eq(:nosuch)
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
myrrha-3.1.0 spec/coercions/test_belongs_to.rb
myrrha-3.0.0 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc7 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc6 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc5 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc4 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc3 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc2 spec/coercions/test_belongs_to.rb
myrrha-3.0.0.rc1 spec/coercions/test_belongs_to.rb
myrrha-2.0.0 spec/coercions/test_belongs_to.rb