Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about examples which don't assert anything? #2097

Closed
alexdowad opened this issue Oct 22, 2015 · 1 comment
Closed

Warn about examples which don't assert anything? #2097

alexdowad opened this issue Oct 22, 2015 · 1 comment

Comments

@alexdowad
Copy link

I'm not very sure about this idea, and would like to hear what the maintainers think. What would you think of making RSpec warn about examples which don't contain any assertions, or anything which could make the test fail?

Of course, any test can fail if it raises an uncaught exception. But if the tester's intention is to just check for uncaught exceptions, it would be better to use expect { ... }.not_to raise_error, to express that intention explicitly.

Where this came from: I am just updating a RSpec 2 suite to RSpec 3, and I discovered some old, forgotten "tests" which don't test anything at all. They look something like this:

it "returns the right value" do
  actual.value == expected.value
end

I'm sure that the author meant actual.value.should == expected.value.

@myronmarston
Copy link
Member

Yes, this is a worthwhile idea, and in fact it's already on the roadmap (see #759). Closing this issue so conversation can stay in that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants