Sha256: 5017cbc25c733c412e01db9cc17c77176812aec98c77d357c8889323f696b8c3

Contents?: true

Size: 717 Bytes

Versions: 38

Compression:

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

38 entries across 38 versions & 7 rubygems

Version Path
deckshuffler-0.0.2 vendor/plugins/rspec/examples/partial_mock_example.rb
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/examples/partial_mock_example.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/examples/partial_mock_example.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/examples/partial_mock_example.rb
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.0 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.1 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.4 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.2 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.3 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.6 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.5 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.7 rails_plugins/rspec/examples/pure/partial_mock_example.rb
picolena-0.1.8 rails_plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.5.1 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.5 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.6 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.7 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.9 vendor/plugins/rspec/examples/pure/partial_mock_example.rb
radiant-0.6.8 vendor/plugins/rspec/examples/pure/partial_mock_example.rb