Skip to content

Commit

Permalink
[core] Merge pull request rspec/rspec-core#2704 from marcandre/rspec_…
Browse files Browse the repository at this point in the history
…opt_array

Fixes when given an array as `rspec_opt`

---
This commit was imported from rspec/rspec-core@664283f.
  • Loading branch information
JonRowe committed Mar 18, 2020
1 parent a423907 commit fbd42f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rspec-core/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 rspec-core/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 fbd42f1

Please sign in to comment.