Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec throws argument error while using -f formatter

I am using ruby and rspec to write automated test cases along with watir.

C:\Users\san\Dragon>gem list 'rspec'

*** LOCAL GEMS ***

rspec (3.4.0, 2.14.1)
rspec-core (3.4.3, 2.14.8)
rspec-expectations (3.4.0, 2.14.5)
rspec-mocks (3.4.1, 2.14.6)
rspec-support (3.4.1)

When I run the test case using following command.

C:\Users\san\Dragon>rspec -f spec\sampletest_spec.rb:65

I got this error

C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/formatters.rb:173:in `find_formatter': Formatter 'spec\sampletest_spec.rb:65' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-.4.3/lib/rspec/core/formatters.rb:141:in `add'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration.rb:767:in `add_formatter'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `block in load_formatters_into'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `each'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:114:in `load_formatters_into'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/configuration_options.rb:23:in `configure'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:105:in `setup'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:92:in `run'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:78:in `run'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/lib/rspec/core/runner.rb:45:in `invoke'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-3.4.3/exe/rspec:4:in `<top (required)>'
    from C:/Ruby193/bin/rspec:23:in `load'
    from C:/Ruby193/bin/rspec:23:in `<main>'

Getting same error also for

rspec spec\sampletest_spec.rb --format documentation
rspec --format spec\sampletest_spec.rb

like image 804
Sandeep Avatar asked Jul 23 '26 23:07

Sandeep


1 Answers

You are messing things up. --format/-f parameter expects the format description itself to be passed to it, while you are passing the name of the test file.

I have no clue, why there are problems with

rspec spec\sampletest_spec.rb --format documentation

this one must work. But anyway, the easiest solution would be to create .rspec file in the project root directory, having the following content:

--format documentation

yes, the only line. As you have this file created, simply run

rspec spec\sampletest_spec.rb

RSpec will read a configuration from this file and apply the desired format.

like image 130
Aleksei Matiushkin Avatar answered Jul 28 '26 16:07

Aleksei Matiushkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!