Sha256: 4eadbeb293b7553f6a6d4807b5581056c0a615362c2b9cca8e95d0b41f3b9921

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

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

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

  it "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

  it "should fail if target does not respond to #has_sym?" do
    lambda {
      Object.new.should have_key(:a)
    }.should raise_error(NoMethodError)
  end
  
  it "should reraise an exception thrown in #has_sym?(*args)" do
    o = Object.new
    def o.has_sym?(*args)
      raise "Funky exception"
    end
    lambda { o.should have_sym(:foo) }.should raise_error("Funky exception")
  end
end

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

  it "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

  it "should fail if target does not respond to #has_sym?" do
    lambda {
      Object.new.should have_key(:a)
    }.should raise_error(NoMethodError)
  end
  
  it "should reraise an exception thrown in #has_sym?(*args)" do
    o = Object.new
    def o.has_sym?(*args)
      raise "Funky exception"
    end
    lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception")
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
radiant-0.6.5.1 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
radiant-0.6.5 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
radiant-0.6.6 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
radiant-0.6.7 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
radiant-0.6.8 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
radiant-0.6.9 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
rspec-0.0.10 spec/spec/matchers/has_spec.rb
rspec-1.1.4 spec/spec/matchers/has_spec.rb
spree-0.4.0 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
spree-0.4.1 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
spree-0.5.0 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
spree-0.5.1 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb