Sha256: 4879baedc92d3549a138f418f5c3deeac8d1230cc71d205f68e7da447c6369a9

Contents?: true

Size: 1.02 KB

Versions: 37

Compression:

Stored size: 1.02 KB

Contents

Feature: expect a message on any instance of a class

  Use `expect_any_instance_of(Class).to receive` to set an expectation that one
  (and only one) instance of a class receives a message before the example is
  completed. The spec will fail if no instance receives a message.

  Scenario: expect a message on any instance of a class
    Given a file named "example_spec.rb" with:
      """ruby
      describe "expect_any_instance_of" do
        before do
          expect_any_instance_of(Object).to receive(:foo).and_return(:return_value)
        end

        it "verifies that one instance of the class receives the message" do
          o = Object.new
          expect(o.foo).to eq(:return_value)
        end

        it "fails unless an instance receives that message" do
          o = Object.new
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain "2 examples, 1 failure"
    And the output should contain "1) expect_any_instance_of fails unless an instance receives that message"

Version data entries

37 entries across 37 versions & 8 rubygems

Version Path
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
dxruby_rp5-0.0.3 spec/vendor/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
dxruby_rp5-0.0.2 spec/vendor/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
dxruby_rp5-0.0.1 spec/vendor/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/rspec-mocks-2.14.4/features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.99.0.beta1 features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.14.4 features/message_expectations/expect_any_instance_of.feature
clickable_link-0.0.2 vendor/bundle/ruby/1.9.1/gems/rspec-mocks-2.14.3/features/message_expectations/expect_any_instance_of.feature
syllable_counter-1.0.0 vendor/bundle/gems/rspec-mocks-2.14.3/features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.14.3 features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.14.2 features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.14.1 features/message_expectations/expect_any_instance_of.feature
rspec-mocks-2.14.0 features/message_expectations/expect_any_instance_of.feature