Sha256: 70685ebdbbdf4c8966e448f06d85a18c0a13e99e3f76adc86af3177c97d180e7

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

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

describe Object, "#should" do
  before(:each) do
    @target = "target"
    @matcher = mock("matcher")
    @matcher.stub!(:matches?).and_return(true)
    @matcher.stub!(:failure_message)
  end
  
  it "should accept and interact with a matcher" do
    @matcher.should_receive(:matches?).with(@target).and_return(true)    
    @target.should @matcher
  end
  
  it "should ask for a failure_message when matches? returns false" do
    @matcher.should_receive(:matches?).with(@target).and_return(false)
    @matcher.should_receive(:failure_message).and_return("the failure message")
    lambda {
      @target.should @matcher
    }.should fail_with("the failure message")
  end
end

describe Object, "#should_not" do
  before(:each) do
    @target = "target"
    @matcher = mock("matcher")
  end
  
  it "should accept and interact with a matcher" do
    @matcher.should_receive(:matches?).with(@target).and_return(false)
    @matcher.stub!(:negative_failure_message)
    
    @target.should_not @matcher
  end
  
  it "should ask for a negative_failure_message when matches? returns true" do
    @matcher.should_receive(:matches?).with(@target).and_return(true)
    @matcher.should_receive(:negative_failure_message).and_return("the negative failure message")
    lambda {
      @target.should_not @matcher
    }.should fail_with("the negative failure message")
  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
dchelimsky-rspec-1.1.11.7 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.1 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.13 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.2 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.3 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.4 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.5 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.6 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/expectations/extensions/object_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/expectations/extensions/object_spec.rb
newbamboo-evented-rspec-1.1.12 spec/spec/expectations/extensions/object_spec.rb
newbamboo-rspec-1.1.12 spec/spec/expectations/extensions/object_spec.rb
rspec-1.1.12 spec/spec/expectations/extensions/object_spec.rb
rspec-1.2.2 spec/spec/expectations/extensions/object_spec.rb
rspec-1.2.1 spec/spec/expectations/extensions/object_spec.rb
rspec-1.2.0 spec/spec/expectations/extensions/object_spec.rb