Skip to content

Commit

Permalink
Fix treatment of rake task option as an Array.
Browse files Browse the repository at this point in the history
Found because `array =~ /.../` is deprecated in 2.7 and
generates a warning in Ruby 2.6.
  • Loading branch information
marcandre committed Mar 15, 2020
1 parent 7b4b2b9 commit e894c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/core/rake_task.rb
Expand Up @@ -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/ }
"--pattern #{escape pattern}"
else
# Before RSpec 3.1, we used `FileList` to get the list of matched
Expand Down
7 changes: 7 additions & 0 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -77,6 +77,13 @@ def spec_command
exclude(escape(RSpec::Core::RakeTask::DEFAULT_PATTERN))
)
end

it 'behaves properly if rspec_opts is an array' do
task.rspec_opts = %w[--pattern some_specs]
expect(spec_command).to include("--pattern some_specs").and(
exclude(escape(RSpec::Core::RakeTask::DEFAULT_PATTERN))
)
end
end

context "with pattern" do
Expand Down

0 comments on commit e894c64

Please sign in to comment.