Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Don't include default pattern when user specifies their own in Rake task. #2305

Merged
merged 1 commit into from
Jul 28, 2016

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Jul 27, 2016

When configuring rspec via Rake task and a developer specifies a pattern via rspec_opts, don't include the default pattern. Should fix #2303.

@@ -66,6 +66,11 @@ def spec_command
task.rspec_opts = "-Ifoo"
expect(spec_command).to match(/#{task.rspec_path}.*-Ifoo/)
end

it 'wont add --pattern if rspec_opts includes --pattern' do
Copy link
Member

Choose a reason for hiding this comment

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

s/wont/does not/

(At least, we tend to use present-tense "does not" everywhere else in doc strings like these instead of future-tense "will not").

Copy link
Member

Choose a reason for hiding this comment

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

Also, this doc string is confusing. It looks like it does show that it adds --pattern if rspec_opts includes --pattern. How about:

it 'does not add the default --pattern if `rspec_opts` includes --pattern'

@myronmarston
Copy link
Member

Weird, this PR didn't build on travis. Not sure why :(.

Anyhow, I definitely think that the change here is appropriate (if the user has configured --pattern in rspec_opts there's no reason to include the default pattern, too) but I think there's still a bug in the logic in #2002 that this does not address. My understanding of #2002 is that it ORs together multiple patterns -- meaning that any spec files matching any of the patterns should get included in the loaded spec files. But we are seeing in the case reported in #2303 that it does not work properly. It seems like if someone runs rspec --pattern pattern1 --pattern default_patern (where pattern1 is the pattern from example repo #2303) nothing would run and it would be a bug.

Do you have any plans to look more into that, @JonRowe?

@JonRowe
Copy link
Member Author

JonRowe commented Jul 27, 2016

My understanding of #2002 is that it ORs together multiple patterns -- meaning that any spec files matching any of the patterns should get included in the loaded spec files. But we are seeing in the case reported in #2303 that it does not work properly. It seems like if someone runs rspec --pattern pattern1 --pattern default_pattern (where pattern1 is the pattern from example repo #2303) nothing would run and it would be a bug.

It actually did work for me on 3.5.0, and is working when pattern is used, because it's escaped, it's the fact the pattern is unescaped causes the misbehaviour, I'm not sure what to do about that...

@JonRowe JonRowe force-pushed the dont_double_include_pattern branch from feda686 to 368a63c Compare July 27, 2016 23:16
@myronmarston
Copy link
Member

actually did work for me on 3.5.0, and is working when pattern is used, because it's escaped, it's the fact the pattern is unescaped causes the misbehaviour, I'm not sure what to do about that...

Strange, when I played around with the repo from #2303 I shellescaped the pattern (since I was getting a different error w/o it), and saw the exact issue reported by @xmik in #2303. Did you try applying the patch I posted in that issue that allowed me to repro the issue?

@myronmarston
Copy link
Member

Changes here LGTM, merge when green.

@JonRowe
Copy link
Member Author

JonRowe commented Jul 27, 2016

It's the one in rspec_opts that needs shell escaping, I was getting the reported behaviour identically on 3.3.x and 3.4.x whilst using it in my own project was working on 3.5.x

@myronmarston
Copy link
Member

It's the one in rspec_opts that needs shell escaping, I was getting the reported behaviour identically on 3.3.x and 3.4.x whilst using it in my own project was working on 3.5.x

I know, my patch escaped the alternate pattern everywhere it appeared, including in rspec_opts. Did you try applying my patch?

@JonRowe JonRowe merged commit 8c84d91 into master Jul 28, 2016
@JonRowe JonRowe deleted the dont_double_include_pattern branch July 28, 2016 11:09
JonRowe added a commit that referenced this pull request Jul 28, 2016
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Don't include default pattern when user specifies their own in Rake task.
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rake task regression? Runs 0 examples since RSpec 3.4.0
2 participants