To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorwarn when expectation is set on nil
- Scenarios
-
- 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"
- 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"
- 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"
Last published over 7 years ago by .