RakeTask.rspec_opts are ignored if specified in the rake

I have a RakeTask that is defined in the test.rake file as

RSpec::Core::RakeTask.new(:pit) do |spec|
  spec.ruby_opts = "-I lib:spec"
  spec.rspec_opts = "--format html --out output.html --format documentation"
  spec.pattern = 'test.rb'
end

task :pi => [:report, :pit]

When i run the command

rake -f test.rake pi

the test runs fine, however I don't see any output according to the documentation format and output.html is not generated.

However, when I run the command

rspec test.rb --format html --out output.html - format documentation

the test works fine, and the output is printed in documentation format, and output.html is also generated correctly.

When I run the rake command, I can also see the arguments correctly, the actual command looks like

ruby.exe -I lib: spec -S rspec test.rb --format html --out output.html - formatted documentation

, , . .

+5
1

,

spec.rspec_opts "--format documentation --color"

- .

spec_helper.rb - rake task

RSpec.configure do |config|
  config.color = true
  config.tty = true
  config.formatter = :documentation # :progress, :html, :textmate
end
0

All Articles