Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle exec rake runs minitest with cucumber options and raises exception #252

Closed
pbollenbeck opened this issue Jul 9, 2013 · 8 comments

Comments

@pbollenbeck
Copy link

Probably an unintended side effect of extraction of autorun suppression into multi_test.

In your shell:

rails new cuke-test
cd cuke-test

Edit ./Gemfile

# [...]
gem 'cucumber-rails', require: false
gem 'database_cleaner'

Setup Cucumber and run tests

bundle
rails g cucumber:install
rake db:create db:migrate db:test:prepare
bundle exec rake

Output:

0 scenarios
0 steps
0m0.000s
/Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:1037:in `block in process_args': invalid option: --profile (OptionParser::InvalidOption)
    from /Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `new'
    from /Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:1016:in `process_args'
    from /Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:1066:in `_run'
    from /Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:1059:in `run'
    from /Users/pbollenbeck/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/minitest-4.7.5/lib/minitest/unit.rb:795:in `block in autorun'

Bundle:

cuke-test % bundle show
Gems included by the bundle:
  * actionmailer (4.0.0)
  * actionpack (4.0.0)
  * activemodel (4.0.0)
  * activerecord (4.0.0)
  * activerecord-deprecated_finders (1.0.3)
  * activesupport (4.0.0)
  * arel (4.0.0)
  * atomic (1.1.10)
  * builder (3.1.4)
  * bundler (1.3.5)
  * capybara (2.1.0)
  * coffee-rails (4.0.0)
  * coffee-script (2.2.0)
  * coffee-script-source (1.6.3)
  * cucumber (1.3.3)
  * cucumber-rails (1.3.0)
  * database_cleaner (1.0.1)
  * diff-lcs (1.2.4)
  * erubis (2.7.0)
  * execjs (1.4.0)
  * gherkin (2.12.0)
  * hike (1.2.3)
  * i18n (0.6.4)
  * jbuilder (1.4.2)
  * jquery-rails (3.0.2)
  * json (1.8.0)
  * mail (2.5.4)
  * mime-types (1.23)
  * mini_portile (0.5.1)
  * minitest (4.7.5)
  * multi_json (1.7.7)
  * multi_test (0.0.1)
  * nokogiri (1.6.0)
  * polyglot (0.3.3)
  * rack (1.5.2)
  * rack-test (0.6.2)
  * rails (4.0.0)
  * railties (4.0.0)
  * rake (10.1.0)
  * rdoc (3.12.2)
  * sass (3.2.9)
  * sass-rails (4.0.0)
  * sdoc (0.3.20)
  * sprockets (2.10.0)
  * sprockets-rails (2.0.0)
  * sqlite3 (1.3.7)
  * thor (0.18.1)
  * thread_safe (0.1.0)
  * tilt (1.4.1)
  * treetop (1.4.14)
  * turbolinks (1.2.0)
  * tzinfo (0.3.37)
  * uglifier (2.1.1)
  * xpath (2.0.0)

Environment:

  • Ruby 2.0.0-p247 (also fails in p195)
  • Bundler 1.3.5
  • Rails 4.0.0
@pbollenbeck
Copy link
Author

Once you fix the cucumber version to 1.3.2, everything works as expected.

@wtfiwtz
Copy link

wtfiwtz commented Jul 10, 2013

Rails 4, Nokogiri and Cucumber seem to have a dependancy on Minitest 4.x... but its passing RSpec options (--profile) to Test::Unit or Minitest...

Locking cucumber on version 1.3.2 didn't work for me...

I've tried commenting out the 'require' lines in spec_helper.rb but this hasn't helped.

(I'm on Rails 4.0.0, Ruby 2.0.0p247)

@wtfiwtz
Copy link

wtfiwtz commented Jul 11, 2013

Okay, if I run "cucumber" rather than "rake cucumber" it seems to work fine - with both cucumber 1.3.3 and 1.3.2. Is there something being loaded by rake that is linking things to Test::Unit or Minitest?

@wtfiwtz
Copy link

wtfiwtz commented Jul 11, 2013

Okay, if you provide any options to cucumber it triggers the autorun behaviour.

I added this to features/support/env.rb ( before require 'cucumber/rails' ):

   # This is taken from here: https://groups.google.com/forum/#!topic/cukes/VoLUFDbiNdc
   require 'minitest/unit'
   module SurpressAutorun
     attr_accessor :installed_at_exit
   end
   MiniTest::Unit.extend SurpressAutorun
   module MiniTest
     class Unit
       @@installed_at_exit = false
     end
   end

Credit goes to these guys...

https://groups.google.com/forum/#!topic/cukes/VoLUFDbiNdc
https://github.com/cucumber/cucumber/blob/693c532fc5d104c1879ac1171ce0d13b26824685/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb#L2

@mattwynne
Copy link
Member

Related to #253 I'd guess.

@joshuavial
Copy link

The fix in cucumber/multi_test#2 worked for me

@Kosmas
Copy link
Member

Kosmas commented Aug 29, 2013

Closing as it's relevent to fix #253

@bjoerne2
Copy link

My solution is similar to yours, @wtfiwtz, but I had to change a few details, as Minitest changed their code a little bit and env.rb was too late. I added an initializer (config/initializers/suppress_minitest.rb) with this content:

# This is taken from here: https://groups.google.com/forum/#!topic/cukes/VoLUFDbiNdc
require 'minitest'

module Minitest
  @@installed_at_exit = true
end

lostie pushed a commit to ministryofjustice/Claim-for-Crown-Court-Defence that referenced this issue Jun 28, 2018
More details here: cucumber/cucumber-rails#252

Also, given that guard-cucumber current version does not support the
most recent version of cucumber, I've choosen to remove it from the
Guardfile options. I would argue that is not critical to have that
running everytime there's changes, more relevant for unit tests (RSpec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants