Sha256: f2e58453c38b2cb8d82b167a5e221bee56c7d5b41ece3b400100969bccedab54

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

Feature: warn when expectation is set on nil

  Scenario: nil instance variable
    Given a file named "example_spec.rb" with:
      """
      RSpec.configure {|c| c.mock_with :rspec}
      describe "something" do
        it "does something" do
          @i_do_not_exist.should_receive(:foo)
          @i_do_not_exist.foo
        end
      end
      """
    When I run "rspec ./example_spec.rb"
    Then the output should contain "An expectation of :foo was set on nil"

  Scenario: allow
    Given a file named "example_spec.rb" with:
      """
      RSpec.configure {|c| c.mock_with :rspec}
      describe "something" do
        it "does something" do
          allow_message_expectations_on_nil
          nil.should_receive(:foo)
          nil.foo
        end
      end
      """
    When I run "rspec ./example_spec.rb"
    Then the output should not contain "An expectation"

  Scenario: allow in one example, but not on another
    Given a file named "example_spec.rb" with:
      """
      RSpec.configure {|c| c.mock_with :rspec}
      describe "something" do
        it "does something (foo)" do
          allow_message_expectations_on_nil
          nil.should_receive(:foo)
          nil.foo
        end
        it "does something (bar)" do
          nil.should_receive(:bar)
          nil.bar
        end
      end
      """
    When I run "rspec ./example_spec.rb"
    Then the output should contain "An expectation of :bar"
    And  the output should not contain "An expectation of :foo"

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/features/message_expectations/warn_when_expectation_is_set_on_nil.feature
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-mocks-2.5.0/features/message_expectations/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.5.0 features/message_expectations/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.4.0 features/message_expectations/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.rc features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.22 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.20 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.19 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.18 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.17 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.16 features/mocks/warn_when_expectation_is_set_on_nil.feature