Sha256: 4cb2ccb14ed0adde8450fabf59fcf2f4e80664a0379f1f16610225177d0ae5fc

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

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

context "should have_sym(*args)" do
  specify "should pass if #has_sym?(*args) returns true" do
    {:a => "A"}.should have_key(:a)
  end

  specify "should fail if #has_sym?(*args) returns false" do
    lambda {
      {:b => "B"}.should have_key(:a)
    }.should fail_with("expected #has_key?(:a) to return true, got false")
  end

  specify "should fail if target does not respond to #has_sym?" do
    lambda {
      Object.new.should have_key(:a)
    }.should raise_error(NoMethodError)
  end
end

context "should_not have_sym(*args)" do
  specify "should pass if #has_sym?(*args) returns false" do
    {:a => "A"}.should_not have_key(:b)
  end

  specify "should fail if #has_sym?(*args) returns true" do
    lambda {
      {:a => "A"}.should_not have_key(:a)
    }.should fail_with("expected #has_key?(:a) to return false, got true")
  end

  specify "should fail if target does not respond to #has_sym?" do
    lambda {
      Object.new.should have_key(:a)
    }.should raise_error(NoMethodError)
  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/matchers/has_spec.rb
rspec-0.8.0 spec/spec/matchers/has_spec.rb
rspec-0.8.1 spec/spec/matchers/has_spec.rb
rspec-0.8.2 spec/spec/matchers/has_spec.rb