Rspec fails with 'invalid option' even though the option is valid. Is this a bug in rspec?

StackOverflow https://stackoverflow.com/questions/23617909

  •  21-07-2023
  •  | 
  •  

Question

When I run $ bundle exec rspec spec --format progress it gives this error:

..*....invalid option: --format
F**..**..***................*.*********

Even though that's a valid option. When I run the test with rspec or bundle exec rspec then all tests pass. The test that fails is

  1) Refinery::PagesController get all the methods succeeds
     Failure/Error: rake.init
     SystemExit:
       exit
     # ./spec/controllers/refinery/pages_controller_spec.rb:64:in `block (2 levels) in <top (required)>'

The spec that fails is

require 'spec_helper'
require 'refinery/pages_controller'
require "rake"

describe Refinery::PagesController do
  render_views
  
  before do 
...
    # http://stackoverflow.com/questions/13704976/how-to-call-a-rake-task-in-rspec
    rake = Rake::Application.new
    Rake.application = rake
    rake.init                         ### LINE 64
    rake.load_rakefile
    rake['categories:create'].invoke

Why don't I just run rspec command instead? Because CircleCI(.com - continuous integration server) is the one that sets the command line and we don't have control over that.

Versions

Rails 3.2.14

$ gem list rspec
rspec (2.14.1)
rspec-core (2.14.8, 2.14.7)
rspec-expectations (2.14.5, 2.14.4)
rspec-mocks (2.14.6, 2.14.4)
rspec-rails (2.14.2, 2.14.1)

Gemfile.lock:    rspec (2.14.1)
Gemfile.lock:    rspec-core (2.14.7)
Gemfile.lock:    rspec-expectations (2.14.4)
Gemfile.lock:    rspec-mocks (2.14.4)
Gemfile.lock:    rspec-rails (2.14.1)
Était-ce utile?

La solution 2

I work for CircleCI and this came across my radar.

You can set custom test commands, including overriding Circle's built-in code/test inference, using your circle.yml file. In your case, setting something like:

test:
  override:
    - rspec

would fit the bill and would cause rspec to run instead of bundle exec rspec spec --format progress

Autres conseils

If your dependencies are managed with bundler you should go with:

test:
  override:
    - bundle exec rspec

so that your bundle is available

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top