Sha256: a1e667e3c949b2ce768e9d3fbc3794a883c72fb86f854f48846d62333749c7c0

Contents?: true

Size: 718 Bytes

Versions: 82

Compression:

Stored size: 718 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

82 entries across 82 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 examples/pure/partial_mock_example.rb
dchelimsky-rspec-1.1.11.1 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.2 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.3 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.4 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.5 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.6 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11.7 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.11 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.12 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.1 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.13 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.2 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.3 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.4 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.5 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.6 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.7 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.8 examples/passing/partial_mock_example.rb
dchelimsky-rspec-1.1.99.9 examples/passing/partial_mock_example.rb