Sha256: 44afa3d7aa0ff5e0d6ecde63da88976f468c2b8fc93ffdc3d3002908313210a2

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 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 I should see "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 I should not see "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 I should see "An expectation of :bar"
    And  I should not see "An expectation of :foo"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-mocks-2.0.0.beta.8 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.7 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.6 features/mocks/warn_when_expectation_is_set_on_nil.feature
rspec-mocks-2.0.0.beta.5 features/mocks/warn_when_expectation_is_set_on_nil.feature