Sha256: 305767611e237fd918f2799c040caf8221c9648dcf068d1303e00b3814b967c9
Contents?: true
Size: 1.61 KB
Versions: 23
Compression:
Stored size: 1.61 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe "spec matchers" do describe "be_model_with_values matcher" do it "should match a models values if they are all in the expected hash" do dude = MockModel.new({:kid_date=>1, :kid_time=>2}) dude.should be_model_with_values( {:kid_date=>1, :kid_time=>2} ) end it "should match (as strings) a models values if they are all in the expected hash" do dude = MockModel.new({:kid_date=>"1", :kid_time=>"2"}) dude.should be_model_with_values_as_strings( {:kid_date=>1, :kid_time=>2} ) end it "should fail match for models values if they are in the expected hash but of wrong type" do dude = MockModel.new({:kid_date=>1, :kid_time=>"2"}) begin dude.should be_model_with_values( {:kid_date=>1, :kid_time=>2} ) rescue => e e.message.should match("unequal values: \nexpected: \\{:kid_time=>2\\} \n but got:\n\\{:kid_time=>\"2\"\\}") end end it "should fail if model does not have all the keys as expected hash" do dude = MockModel.new({:kid_date=>1}) begin dude.should be_model_with_values( {:kid_date=>1, :kid_time=>2} ) rescue => e e.message.should match("missing keys: \\[:kid_time\\]") end end it "should fail if one of the values does not match" do dude = MockModel.new( {:kid_date=>1, :kid_time=>3} ) begin dude.should be_model_with_values( {:kid_date=>1, :kid_time=>2} ) rescue => e e.message.should match("unequal values: \nexpected: \\{:kid_time=>2\\} \n but got:\n\\{:kid_time=>3\\}") end end end end
Version data entries
23 entries across 23 versions & 1 rubygems