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

Fixes when given an array as rspec_opt #2704

Merged
merged 2 commits into from Mar 18, 2020
Merged

Conversation

marcandre
Copy link
Contributor

Rspec raketask's rspec_opt accepts a string or an array of strings.

In Ruby 2.7 a deprecation warning is generated for arrays. This led me to find and error that was undetected because there is no spec for the array case. Moreover I realized that the existing spec for string was erroneously written. This PR fixes both issues

…succeeding.

We really should have `include(...).once` as an available matcher.
rspec/rspec-expectations#685
Found because `array =~ /.../` is deprecated in 2.7 and
generates a warning in Ruby 2.6.
@marcandre marcandre changed the title Rspec opt array Fixes when given an array as rspec_opt Mar 15, 2020
@@ -122,7 +122,7 @@ def file_inclusion_specification
if ENV['SPEC']
FileList[ENV['SPEC']].sort
elsif String === pattern && !File.exist?(pattern)
return if rspec_opts =~ /--pattern/
return if [*rspec_opts].any? { |opt| opt =~ /--pattern/ }
Copy link
Member

Choose a reason for hiding this comment

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

Wondering where rspec_opts is coming from. I could only find it being assigned a nil 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.

It's a writable attribute, so it can be set directly on the task

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an example using an array.

Copy link
Member

@pirj pirj 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, thanks!

@JonRowe JonRowe merged commit 50e9c7f into rspec:master Mar 18, 2020
JonRowe added a commit that referenced this pull request Mar 18, 2020
@JonRowe
Copy link
Member

JonRowe commented Mar 18, 2020

Thanks!

JonRowe added a commit that referenced this pull request Mar 18, 2020
Fixes when given an array as `rspec_opt`
JonRowe added a commit that referenced this pull request Mar 18, 2020
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Fixes when given an array as `rspec_opt`
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…opt_array

Fixes when given an array as `rspec_opt`

---
This commit was imported from rspec/rspec-core@664283f.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
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

3 participants