Sha256: c1055d2ea9fdeae3c71797dca91c29a755e8539e63737d751c0c1616c891c728

Contents?: true

Size: 1.1 KB

Versions: 38

Compression:

Stored size: 1.1 KB

Contents

Feature: Spy on a stubbed method on a partial mock

  You can also use `have_received` to verify that a stubbed method was invoked
  on a partial mock.

  Scenario: verify a stubbed method
    Given a file named "verified_spy_spec.rb" with:
      """ruby
      describe "have_received" do
        it "passes when the expectation is met" do
          invitation = Object.new
          invitation.stub(:deliver => true)
          invitation.deliver
          invitation.should have_received(:deliver)
        end
      end
      """
    When I run `rspec verified_spy_spec.rb`
    Then the examples should all pass

  Scenario: fail to verify a stubbed method
    Given a file named "failed_spy_spec.rb" with:
      """ruby
      describe "have_received" do
        it "fails when the expectation is not met" do
          invitation = Object.new
          invitation.stub(:deliver => true)
          invitation.should have_received(:deliver)
        end
      end
      """
    When I run `rspec failed_spy_spec.rb`
    Then the output should contain "expected: 1 time"
     And the output should contain "received: 0 times"

Version data entries

38 entries across 38 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.4 features/spies/spy_partial_mock_method.feature
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-mocks-2.14.6/features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.3 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.2 features/spies/spy_partial_mock_method.feature
dxruby_rp5-0.0.4 spec/vendor/rspec-mocks-2.14.4/features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.1 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.0 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.0.rc1 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.14.6 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.99.0.beta2 features/spies/spy_partial_mock_method.feature
rspec-mocks-2.14.5 features/spies/spy_partial_mock_method.feature
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-mocks-2.14.4/features/spies/spy_partial_mock_method.feature