'invalid option: --format' when executing rspec

Hi all -- I'm getting 'invalid option: --format' when I try to run rspec tests in IntelliJ.  I can't seem to sort out why this is happening.  Here's a typical console output:

/home/mark/.rvm/rubies/jruby-1.7.20/bin/jruby -J-cp /home/mark/standalone-test/pods/out/test/pods --1.9 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/mark/.rvm/gems/jruby-1.7.20@mywave-pods/bin/rspec /home/mark/standalone-test/pods/spec/decorators/deleted_pod_decorator_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --example "DeletedPodDecorator.links responds with links"

Testing started at 10:09 AM ...

invalid option: --format


This would seem to be in reference to the " --format Spec::Runner::Formatter::TeamcityFormatter" part of the command -- not sure what that does, if that's necessary, or why it's not understood by the jruby executable.  Any insight you provide would be greatly appreciated...
2

How do you run rspec files? From context menu, or you create run configuration manually?

0

From the context menu, but I've tried tweaking various options on the run configuration that gets created as a result without any luck.

0

Anyone have any ideas?  I've been unable to run my specs from within Intellij for close to a year now.

0

Mark, what IDEA and Ruby plugin versions do you have? In case you remove all existing Run configurations and launch "All specs in.." or a singe test, how does it go? In addition, how does it go from the command line (when launched manually)?

0
Avatar
Permanently deleted user

I am also experiencing this problem in RubyMine 2016.2.3 Build #RM-162.1812.23, built on September 5, 2016

I get the same results regardless of how I attempt to execute specs, whether as a single test or "All specs in...".  I have no problem running these specs from the command line, as long as I do not use the --format option

The output pasted below is similar to what was reported by Mark Schnitzius:

 

/Users/michaelarnold/.rvm/rubies/ruby-2.2.3/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/michaelarnold/Development/boxpanel/bin/rspec /Users/michaelarnold/Development/boxpanel/spec/controllers/webhooks_controller_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter
Testing started at 8:40 AM ...
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}


Randomized with seed 2736

0 examples, 0 failures, 0 passed

Finished in 2.011796 seconds


Randomized with seed 2736
invalid option: --format

Process finished with exit code 1
Empty test suite.

0

Hello, Michael,

could you please check how it goes in the last RubyMine 2016.3 EAP? If the problem persists would it possible to provide me with a sample project to reproduce the problem?

0

I've the latest version, still no luck

RubyMine 2022.1.3

Build #RM-221.5921.22, built on June 21, 2022

0

Hello! Can you please share a bit more context around the problem? Which version of Ruby are you using? Could you please share a project where we could reproduce it?

 

0

Oleg Olkhovoy 

It happens when I use stripe-ruby-mock gem for some reason, 

Here is my `spec_helper.rb` file :

require 'require_all'
require 'helpers/authentication_helper'
require 'thin'
require 'stripe_mock'
require_all 'lib/core_extensions'

RSpec.configure do |config|
config.include AuthenticationHelper
StripeMock::Instance.include CoreExtensions::StripeMock::RequestHandlers::Invoices

StripeMock.spawn_server
config.expect_with :rspec do |expectations|

expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups
end

 

I'm getting this error when trying to run rspecs using RubyMine :

/bin/zsh -c "bash -c '/path/to/rvm ruby-2.7.1 do /path/to/rvm/rubies/ruby-2.7.1/bin/ruby -x /path/to/rvm/gems/ruby-2.7.1/bin/bundle exec /path/to/rvm/rubies/ruby-2.7.1/bin/ruby /path/to/rvm/gems/ruby-2.7.1/bin/rspec /path/to/project/spec/models/address_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format '\"'\"'Spec::Runner::Formatter::TeamcityFormatter'\"'\"' --example Address'"
Testing started at 11:09 PM ...

An error occurred while loading spec_helper.
Failure/Error: StripeMock.spawn_server

OptionParser::InvalidOption:
  invalid option: --require
# /Users/shqear/.rvm/gems/ruby-2.7.1/gems/dante-0.2.0/lib/dante/runner.rb:213:in `parse_options'
# /Users/shqear/.rvm/gems/ruby-2.7.1/gems/dante-0.2.0/lib/dante/runner.rb:50:in `execute'
# /Users/shqear/.rvm/gems/ruby-2.7.1/gems/stripe-ruby-mock-3.0.1/lib/stripe_mock/api/server.rb:18:in `spawn_server'
# ./spec/spec_helper.rb:11:in `block in <top (required)>'
# ./spec/spec_helper.rb:7:in `<top (required)>'
Run options: include {:full_description=>/Address/}

All examples were filtered out


Finished in 0.00009 seconds (files took 0.75955 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
0 examples, 0 failures, 0 passed
Finished in 9.0e-05 seconds


Process finished with exit code 1

It is working fine when I run directly on the terminal, I tried to solve the issue with no luck but it seems the error is somewhere in OptionParser#parse! , it seems caused because it's passing options to stripe-mock-server process where it doesn't expect any anguments, I'm not really sure, but I think that is part of the issue, I tried to fix by resetting the options when stripe-mock-server starts, so I made sure to pass empty options and it worked when I do tests with debug, but it doesn't work with normal run, here is how I make it work on debugging, I changed parse! method inside ruby lib itself, basically I reset the options when stripe-mock-server turn comes

def parse!(argv = default_argv, into: nil)
@@cccc = 0 if !defined?(@@cccc)

if @@cccc == 3
7.times { argv.shift }
else
@@cccc += 1
end

if ENV.include?('POSIXLY_CORRECT')
order!(argv, into: into)
else
permute!(argv, into: into)
end
end

 

Oleg Olkhovoy  I believe this github issue is pretty much related will also help, this hack worked for me, but it doesn't feel like a sustainable solution

 

0

请先登录再写评论。