Created
December 17, 2012 01:34
-
-
Save sorah/4315150 to your computer and use it in GitHub Desktop.
Show warnings for examples that has no expectations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
config.after(:each) do | |
result = self.example.metadata[:execution_result] | |
has_mock_expectations = RSpec::Mocks.space.instance_eval{receivers}.empty? | |
if !result[:exception] && !result[:pending_message] && !RSpec::Matchers.last_should && hasnt_mock_expectations | |
$stderr.puts "[WARN] No expectations found in example at #{self.example.location}: Maybe you forgot to write `should` in the example?" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, it's just what I was looking for.
Should the variable on line 4 be
hasnt_mock_expectations
though, since that's what you reference on line 5?