Sha256: 09fe7c74e5b2b406e56b076ffba6bd6032396f0b3be4482a040f3f17598133d9

Contents?: true

Size: 877 Bytes

Versions: 4

Compression:

Stored size: 877 Bytes

Contents

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

context "A consumer of a mock" do
  specify "should be able to send messages to the mock" do
    mock = mock("poke me")
    mock.should_receive(:poke)
    mock.poke
  end
end

context "a mock" do
  specify "should be able to mock the same message twice w/ different args" do
    mock = mock("mock")
    mock.should_receive(:msg).with(:arg1).and_return(:val1)
    mock.should_receive(:msg).with(:arg2).and_return(:val2)
    mock.msg(:arg1).should eql(:val1)
    mock.msg(:arg2).should eql(:val2)
  end

  specify "should be able to mock the same message twice w/ different args in reverse order" do
    mock = mock("mock")
    mock.should_receive(:msg).with(:arg1).and_return(:val1)
    mock.should_receive(:msg).with(:arg2).and_return(:val2)
    mock.msg(:arg2).should eql(:val2)
    mock.msg(:arg1).should eql(:val1)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
riess-0.0.8 vendor/rspec-0.8.2/examples/mocking_example.rb
rspec-0.8.0 examples/mocking_example.rb
rspec-0.8.1 examples/mocking_example.rb
rspec-0.8.2 examples/mocking_example.rb