Sha256: 4de0d63b27819ec390feea23abc1d8c2349d494592687acb78aa5d7bfdc01b58

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

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

context "Object#should" do
  setup do
    @target = "target"
    @matcher = mock("matcher")
    @matcher.stub!(:matches?).and_return(true)
    @matcher.stub!(:failure_message)
  end
  
  specify "should accept and interact with a matcher" do
    @matcher.should_receive(:matches?).with(@target).and_return(true)
    
    @target.should @matcher
  end
  
  specify "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

context "Object#should_not" do
  setup do
    @target = "target"
    @matcher = mock("matcher")
  end
  
  specify "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
  
  specify "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

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/spec/spec/expectations/extensions/object_spec.rb
rspec-0.8.0 spec/spec/expectations/extensions/object_spec.rb
rspec-0.8.1 spec/spec/expectations/extensions/object_spec.rb
rspec-0.8.2 spec/spec/expectations/extensions/object_spec.rb