Skip to content

Commit

Permalink
Merge pull request #2704 from marcandre/rspec_opt_array
Browse files Browse the repository at this point in the history
Fixes when given an array as `rspec_opt`
  • Loading branch information
JonRowe committed Mar 18, 2020
2 parents 725b0d2 + e894c64 commit 50e9c7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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
15 changes: 13 additions & 2 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -62,15 +62,26 @@ def spec_command
end

context "with rspec_opts" do
include RSpec::Core::ShellEscape

it "adds the rspec_opts" do
task.rspec_opts = "-Ifoo"
expect(spec_command).to match(/#{task.rspec_path}.*-Ifoo/)
expect(spec_command).to match(/#{task.rspec_path}.*-Ifoo/).and(
include(escape(RSpec::Core::RakeTask::DEFAULT_PATTERN)) # sanity check for following specs
)
end

it 'correctly excludes the default pattern if rspec_opts includes --pattern' do
task.rspec_opts = "--pattern some_specs"
expect(spec_command).to include("--pattern some_specs").and(
exclude(RSpec::Core::RakeTask::DEFAULT_PATTERN)
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
Expand Down

0 comments on commit 50e9c7f

Please sign in to comment.