Sha256: 0157b46ce3e05a6d99353841e6253a933c6152471e65d8777a6c6278a18a2d43

Contents?: true

Size: 604 Bytes

Versions: 4

Compression:

Stored size: 604 Bytes

Contents

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

context "should_have_key" do
  specify "should pass when key is present" do
    lambda do
      {"a" => 1}.should_have_key("a")
    end.should_not_raise
  end

  specify "should fail when key is not present" do
    lambda do
      {"a" => 1}.should_have_key("b")
    end.should_fail_with('expected #has_key?("b") to return true, got false')
  end

  specify "should fail when target does not respond to has_key?" do
    lambda do
      Object.new.should_have_key("b")
    end.should_fail_with /target does not respond to #has_key\?/
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/spec/spec/expectations/should/should_have_key_spec.rb
rspec-0.8.0 spec/spec/expectations/should/should_have_key_spec.rb
rspec-0.8.1 spec/spec/expectations/should/should_have_key_spec.rb
rspec-0.8.2 spec/spec/expectations/should/should_have_key_spec.rb