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

Fix regression in rails filters #618

Merged
merged 1 commit into from
Sep 2, 2017

Conversation

jenseng
Copy link
Contributor

@jenseng jenseng commented Aug 29, 2017

In converting this to a regex in a0b14a1, an extra leading / was added,
making this filter less useful (it would literally match the /^/db/
path).

@PragTob
Copy link
Collaborator

PragTob commented Aug 29, 2017

👋

Thanks! Could we add a "simple" test case that checks this maybe in the integration test cases so something like this doesn't happen again? :)

@jenseng
Copy link
Contributor Author

jenseng commented Aug 29, 2017

Sure thing 👍

@jenseng
Copy link
Contributor Author

jenseng commented Aug 30, 2017

This approach to testing is a little bit meh... ideally .filtered and friends could be moved onto an object or into Configuration so that they are more easily testable without worrying about breaking the singleton. That feels like a bigger refactor than this little fix though, so ¯\_(ツ)_/¯

@jenseng
Copy link
Contributor Author

jenseng commented Aug 30, 2017

Oh, heh I think I glossed over your comment around feature tests, perhaps I'll just test it there

In converting this to a regex in a0b14a1, an extra leading `/` was added,
making this filter less useful (it would literally match the `/^/db/`
path).
@jenseng
Copy link
Contributor Author

jenseng commented Aug 30, 2017

Upon further reflection, I think I found a decent way to test it at a lower level 🤞

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and great lower level testing! 👍

Only little comment/question about the skipping, could remove that myself but just wanna make sure it doesn't have a special meaning or so!

@@ -155,7 +155,9 @@ def matches?(_)
end
end

context "with the default profile" do
context "with the default configuration" do
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly confused why this is here and not just above? Leftover? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if there's a scenario where you'd run the specs w/ SIMPLECOV_NO_DEFAULTS, but this should ensure the suite still passes in that case, since it has to do with the default filters. Might be worth setting up in Travis?


if SimpleCov.usable?
describe SimpleCov do
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(with other point where it is I mean this here) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same story here, I just wanted to make this resilient in case people run specs with that set, since the profiles won't exist in that case.

configure(&SimpleCov.profiles[name.to_sym])
end
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 using let with anonymous classes! :)

it "provides a sensible rails profile" do
config.load_profile(:rails)
expect(filtered?(config, "app/models/user.rb")).not_to be
expect(filtered?(config, "db/schema.rb")).to be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait whaaaaatttttttttt? You can just use .to be/.not_to be. Touché. I've used rspec forever and consider myself pretty good at it bu you constantly teach me new stuff. Thanks 🙏

config.load_profile(:rails)
expect(filtered?(config, "app/models/user.rb")).not_to be
expect(filtered?(config, "db/schema.rb")).to be
expect(filtered?(config, "config/environment.rb")).to be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 great way of testing it on a lower level, thank you very much! 👍

@PragTob PragTob merged commit f27b23b into simplecov-ruby:master Sep 2, 2017
@PragTob
Copy link
Collaborator

PragTob commented Sep 2, 2017

Thanks a bunch! 🚀

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 18, 2017
0.15.1 (2017-09-11)
=======

## Bugfixes

* Filter directories outside SimpleCov.root that have it as a prefix. See [#617](simplecov-ruby/simplecov#617) (thanks @jenseng)
* Fix standard rails profile rails filter (didn't work). See [#618](simplecov-ruby/simplecov#618) (thanks @jenseng again!)
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

Successfully merging this pull request may close these issues.

None yet

2 participants