Sha256: d28ca172ae9e50b0df82b07179b993330e1069ab18ecf789b927e79195b8ad3d
Contents?: true
Size: 1.87 KB
Versions: 108
Compression:
Stored size: 1.87 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 a models values if they are all in the expected hash even if values hash has symbol keys" 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
108 entries across 108 versions & 1 rubygems