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

Version Path
fossil-0.3.14 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.13 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.12 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.11 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.10 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.9 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.8 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.7 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.6 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.5 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.4 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.3 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.2 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.1 spec/be_model_with_values_matcher_spec.rb
fossil-0.3.0 spec/be_model_with_values_matcher_spec.rb
fossil-0.2.9 spec/be_model_with_values_matcher_spec.rb
fossil-0.2.8 spec/be_model_with_values_matcher_spec.rb
fossil-0.2.7 spec/be_model_with_values_matcher_spec.rb
fossil-0.2.6 spec/be_model_with_values_matcher_spec.rb
fossil-0.2.5 spec/be_model_with_values_matcher_spec.rb