Sha256: 759e30bb7416ec6ad8d48060c0b02e950e1d0b206a9182acca711314a91dd868

Contents?: true

Size: 764 Bytes

Versions: 5

Compression:

Stored size: 764 Bytes

Contents

require 'spec_helper'
module Myrrha
  describe "Coercions#belongs_to?" do
    let(:rules){ Coercions.new }
    
    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

5 entries across 5 versions & 1 rubygems

Version Path
myrrha-1.2.2 spec/coercions/test_belongs_to.rb
myrrha-1.2.1 spec/coercions/test_belongs_to.rb
myrrha-1.2.0 spec/coercions/test_belongs_to.rb
myrrha-1.1.0 spec/coercions/test_belongs_to.rb
myrrha-1.0.0 spec/coercions/test_belongs_to.rb