Sha256: c8be28a019a74754cc0d232016f850951bb9ca7494341dc292527754e9b37fab

Contents?: true

Size: 1.63 KB

Versions: 20

Compression:

Stored size: 1.63 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
  module Mocks
    module ArgumentConstraints
      describe HashIncludingConstraint do
        
        it "should describe itself properly" do
          HashIncludingConstraint.new(:a => 1).description.should == "hash_including(:a=>1)"
        end      

        describe "passing" do
          it "should match the same hash" do
            hash_including(:a => 1).should == {:a => 1}
          end

          it "should match a hash with extra stuff" do
            hash_including(:a => 1).should == {:a => 1, :b => 2}
          end
          
          describe "when matching against other constraints" do
            it "should match an int against anything()" do
              hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2}
            end

            it "should match a string against anything()" do
              hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2}
            end
          end
        end
        
        describe "failing" do
          it "should not match a non-hash" do
            hash_including(:a => 1).should_not == 1
          end


          it "should not match a hash with a missing key" do
            hash_including(:a => 1).should_not == {:b => 2}
          end

          it "should not match a hash with an incorrect value" do
            hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3}
          end

          it "should not match when values are nil but keys are different" do
            hash_including(:a => nil).should_not == {:b => nil}
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 6 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/mocks/hash_including_matcher_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/mocks/hash_including_matcher_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
mack-0.8.2 lib/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb
pictrails-0.5.0 vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.10 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.5 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.11 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.7 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.6 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.9 spec/spec/mocks/hash_including_matcher_spec.rb
rspec-1.1.8 spec/spec/mocks/hash_including_matcher_spec.rb
typo-5.1.98 vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb
typo-5.2 vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb