Sha256: efadf204dfc96cfd195875870b94d63bb5ddbd7be8b25dff892578d7deb1a01a

Contents?: true

Size: 716 Bytes

Versions: 10

Compression:

Stored size: 716 Bytes

Contents

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

class MockableClass
  def self.find id
    return :original_return
  end
end

describe "A partial mock" do

  it "should work at the class level" do
    MockableClass.should_receive(:find).with(1).and_return {:stub_return}
    MockableClass.find(1).should equal(:stub_return)
  end

  it "should revert to the original after each spec" do
    MockableClass.find(1).should equal(:original_return)
  end

  it "can be mocked w/ ordering" do
    MockableClass.should_receive(:msg_1).ordered
    MockableClass.should_receive(:msg_2).ordered
    MockableClass.should_receive(:msg_3).ordered
    MockableClass.msg_1
    MockableClass.msg_2
    MockableClass.msg_3
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspec-0.9.4 examples/partial_mock_example.rb
rspec-0.9.0 examples/partial_mock_example.rb
rspec-0.9.1 examples/partial_mock_example.rb
rspec-0.9.2 examples/partial_mock_example.rb
rspec-0.9.3 examples/partial_mock_example.rb
rspec-1.0.0 examples/partial_mock_example.rb
rspec-1.0.1 examples/partial_mock_example.rb
rspec-1.0.2 examples/partial_mock_example.rb
rspec-1.0.3 examples/partial_mock_example.rb
rspec-1.0.4 examples/partial_mock_example.rb