-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
100% test coverage #1458
100% test coverage #1458
Conversation
@@ -973,5 +993,30 @@ def actual | |||
}.to raise_error(NotImplementedError, /matcher.or matcher` is not supported/) | |||
end | |||
end | |||
|
|||
describe "#expects_call_stack_jump?" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I was least satisfied with - you've fairly consistently avoided thin unit testing in favor of behavioral/usage-flavored tests. But the tests I rigged up for that here were enormous, and I decided that they were complex enough to get in the way (I needed to make custom ruby-class block-accepting matchers that expected and didn't expect call-stack jumps). But I'll take another swing if I'm not imagining that preference, and you think it's worth the ugly.
expect { | ||
expect(3).to matcher_using_surface_descriptions_in(STDOUT) | ||
}.to fail_with(STDOUT.to_s) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was also ugly, because we can't get to the line in question without an instance of IO, and I didn't figure we'd want to open a fixture File for this spec (but if we do, that'd make it nicer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would StringIO work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought as well, but it's actually not a subclass of IO, just duck-typed like it! I assumed so hard I wrote the test and debugged it to find out I was wrong -.-
8a95966
to
d99adb5
Compare
The oldest rubies are failing two of the new tests:
I don't see anything obviously version dependent here, the only thing that seems plausible is this I think this might mean those matchers are allowed and broken in 1.8.7? Which would probably be .. well, I doubt anybody on that version expects first-class support, but once I get 1.8.7 working in a container I can probably fix it at least :-) In the meantime, I guess I should version-limit those tests? If I'm misunderstanding what's going on (which is likely, as I don't feel like I do understand what's going on yet), tell me more legends of how ruby used to be and I will learn again ;-) |
13fa00b
to
f31af7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you!
a58b458
to
c42fc5b
Compare
@pirj - The other two PRs are merged now, so I rebased this on top of |
Let’s tighten it up to 100%, we can always loosen up if there’s something that we can’t reasonably cover. |
(Because they are specific to versions of ruby, and shouldn't affect overall coverage when run outside those versions)
The message is out of date, since ruby 3 has gone _back_ to ignoring the 'inspect' output (this line was probably covered when it was written, but version-specific, though I didn't bother pinning down exactly what version). I updated the spec structure slightly as well, because the original shape made it difficult to determine what the current message actually _was_, but I'm happy to put it back if there's a style preference.
I.. struggled to get coverage on this through more integration-style behavioral tests like we prefer. It ended up being very verbose and complex, and it felt unreasonable for what it was really testing (which was that, when handling custom matchers that don't specify, we treat them as _not_ expecting call-stack jumps)
This is a pretty odd corner case, and I mocked it, since I didn't think we wanted to open a file or socket in our specs for this.
We don't allow `x.should != y`, and we need to test that we don't.
my prior '.==(VALUE)' solution passed linting on modern rubies, but apparently on older rubies it still caused a message like possibly useless use of == in void context This added expectation doesn't _entirely_ belong, but it's not completely out of place, and it convinces the linter/parser not to worry.
98c6f4a
to
da2288b
Compare
In contexts without RSpec::Mocks::Double defined, we don't need to check this, but of course it's always defined in our _rspec tests._
@JonRowe, this one has been waiting for a while, and ought to be fairly safe as it's test-only. I've updated it with latest if you have a minute to comment; apparently I was the only one to introduce uncovered code since the last push 6 weeks ago >.< |
Use skip instead of if
Thank you! |
Well, aside from a few lines in two other PRs (#1457 and #1456) that needed non-spec changes.
First, I found and marked all of the segments that seem to be ruby-version specific, and set them off with
:nocov:
tags. That's in the first commit. Then I started tackling the remaining uncovered lines one at a time, adding tests I believe there to be no non-spec, non-comment changes in this PR, but I'm confident that some of the specs can be done more elegantly. Please, enhance my approaches, rspec wizards :-D