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

rake cucumber fails on new rails 4 project with both rspec and cucumber #253

Merged
merged 3 commits into from
Aug 27, 2013

Conversation

tooky
Copy link
Member

@tooky tooky commented Aug 27, 2013

Just getting started on a new project – my first attempt with Rails 4 – and I've run into a minor snag. I've generated a demo project to show it off here: mathie/broken_cucumber_demo. Having installed and generated cucumber at mathie/broken_cucumber_demo@7474454, running rake or rake cucumber works fine.

However, after installing and generating rspec (in mathie/broken_cucumber_demo@c208712a149059c260bcdbe48ef204d0f42178e1), running rake cucumber results in:

/Users/mathie/.rbenv/versions/2.0.0-p247/bin/ruby -S bundle exec cucumber  --profile default
DEPRECATION WARNING: ActionController::Integration is deprecated and will be removed, use ActionDispatch::Integration instead. (called from require at /Users/mathie/Development/Personal/broken_cucumber_demo/features/support/env.rb:7)
DEPRECATION WARNING: ActionController::IntegrationTest is deprecated and will be removed, use ActionDispatch::IntegrationTest instead. (called from require at /Users/mathie/Development/Personal/broken_cucumber_demo/features/support/env.rb:7)
Using the default profile...
0 scenarios
0 steps
0m0.000s
/Users/mathie/.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/mathie/.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/mathie/.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/mathie/.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/mathie/.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/mathie/.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'

The backtrace suggests some autorun shenanigans, so I tried commenting out require 'rspec/autorun' from the spec helper, but that doesn't seem to have helped.

Any thoughts?

@mathie
Copy link
Contributor Author

mathie commented Jul 25, 2013

I figure it's equally likely to be a problem with rspec, so I've also reported the issue across at rspec/rspec-rails#792.

@JonRowe
Copy link
Contributor

JonRowe commented Jul 25, 2013

The problem is this line which does require 'rails/test_help' which in turn runs this line which does require 'active_support/testing/autorun' causing minitest to kick in after cucumber runs and blows up due to the command line arguments.

@JonRowe
Copy link
Contributor

JonRowe commented Jul 25, 2013

I'm not sure why RSpec causing this kick in but it looks unrelated to me, except maybe it's changing the dependencies.

@mattwynne
Copy link
Member

See also cucumber/multi_test#2

@aslakhellesoy
Copy link
Contributor

@mattwynne
Copy link
Member

cucumber/common#507 is related

@mattwynne
Copy link
Member

See also #256

@Kosmas
Copy link
Member

Kosmas commented Aug 23, 2013

version 1.4.0 is now rails compatible.

@Kosmas Kosmas closed this Aug 23, 2013
@zmoazeni
Copy link

@Kosmas I just upgraded to v1.4.0 and I still get the same minitest errors at the end that @mathie posted above.

@Kosmas Kosmas reopened this Aug 23, 2013
@nthj
Copy link

nthj commented Aug 23, 2013

I can confirm. I just upgraded to 1.4.0 with Rails 4.0 and have the same issue running bundle exec rake cucumber. I also have RSpec installed.

@nthj
Copy link

nthj commented Aug 23, 2013

This fix worked for me. Thanks, @stevenhaddox

@zmoazeni
Copy link

@stevenhaddox's fix worked for me too. Thanks!

@tooky
Copy link
Member

tooky commented Aug 27, 2013

@Kosmas @aslakhellesoy I've added an explicit call to MultiTest.disable_autorun in cucumber/rails - this should ensure that MiniTest no longer runs.

I'm not sure how to add a test for this? The only way I could recreate the error at all was by running cucumber in a new rails project, without using bundle exec. Is bundler load order deterministic?

This should also fix #252.

I had to change the version of cucumber required in the gemspec to get bundler to run locally - should this version of cucumber/rails require the latest version of cucumber?

Would this change mean that we need an explicit dependency on multi_test in cucumber/rails?

@aslakhellesoy
Copy link
Contributor

@tooky, @Kosmas I think a good test for this would be to create a new scenario that replicates what users have seen - a rails project that uses cucumber and rspec. When this successfully fails we can verify that this PR fixes the problem.

@colszowka
Copy link

I can confirm that the disable_autorun bit fixed things for me (I described my problem over here). I have no idea how minitest even got into my cucumber suite though, it is only present as a dependency of activesupport in my project so Bundler shouldn't be auto-requiring it.

@tooky
Copy link
Member

tooky commented Aug 27, 2013

@aslakhellesoy @Kosmas I think all of the rails apps generated by the cucumber-rails tests already include rspec, and they aren't failing?

I've created a test repo at tooky/cucumber-rails-mini-test-at-exit-test

If you checkout the first commit (tooky/cucumber-rails-mini-test-at-exit-test@a29e16c)

and run

bundle
bundle exec rake cucumber

you should see the error caused by MiniTest at_exit firing.

Then checkout the head commit (tooky/cucumber-rails-mini-test-at-exit-test@ e3354d07218034caf4a758392ff74a8d2a12e591) and run the same commands it should work ok.

The second commit specifies this branch in the Gemfile.

@Kosmas
Copy link
Member

Kosmas commented Aug 27, 2013

@aslakhellesoy @tooky Just created a new rails 4 app and installed cucumber.
Cucumber by itself runs fine with no errors.
When you add rspec-rails then there is this error displayed.

I'm just testing your fix @tooky and looks fine, so when the local tests pass I will merge the PR.

@aslakhellesoy Should we do a test that when we add rspec-rails and run rake cucumber it should pass?

Kosmas added a commit that referenced this pull request Aug 27, 2013
`rake cucumber` fails on new rails 4 project with both rspec and cucumber
@Kosmas Kosmas merged commit 974c933 into master Aug 27, 2013
@aslakhellesoy
Copy link
Contributor

Sounds like it's hard to write a cucumber scenario that demonstrates the problem. No big deal - enough people have confirmed that this works. The only problem is catching regressions, but let's see how it goes.

@Kosmas
Copy link
Member

Kosmas commented Aug 27, 2013

Thanks @tooky

@Kosmas
Copy link
Member

Kosmas commented Aug 28, 2013

Just for information, until the new gem version is released to avoid the error you should replace:

gem 'cucumber-rails', :require => false

with:

gem 'cucumber-rails', :require => false, git: 'https://github.com/cucumber/cucumber-rails.git'

and run bundle install again.

@tooky
Copy link
Member

tooky commented Aug 28, 2013

@Kosmas @aslakhellesoy

Just a thought, perhaps this change isn't needed to cucumber-rails after all? I think this line in cucumber, could move to after the support files are loaded. It would then disable autorun if any of the support files load minitest (or test/unit). That should allow cucumber-rails, not to care about how mini-test is disabled.

I'm away camping so can't try it, but the thought just struck me.

@Kosmas
Copy link
Member

Kosmas commented Aug 29, 2013

@tooky That sounds as a good option, but I do not think there is anything to do in cucumber-rails at the moment.
If you try it and works we can try changing it here?

@aslakhellesoy
Copy link
Contributor

It's definitely preferable to fix this in cucumber rather than cucumber-rails. That way, when another cucumber extension pops up, they don't have to replicate the fix.

@mattwynne
Copy link
Member

@tooky @Kosmas @os97673 shall we get this shipped so we don't get more bug reports?

@Kosmas
Copy link
Member

Kosmas commented Sep 23, 2013

@mattwynne when this is changed in cucumber then we can change it here too..

So, @tooky @os97673 please let me know when it's done there, just in case I miss it.

tooky added a commit to cucumber/cucumber-ruby that referenced this pull request Sep 23, 2013
nathanvda added a commit to nathanvda/JohariWindow that referenced this pull request Nov 4, 2013
Some files were missing, but most importantly, because
of an incompatibility between cucumber and rails 4,
I had to use the an unreleased version of cucumber
that fixes that error. See cucumber/cucumber-rails#253
@Loremaster
Copy link

Have something same, error appeared after upgrade on Rails 4: http://stackoverflow.com/questions/21550514/cucumber-tests-suddenly-stops

Tests just suddenly stop. We use cucumber, capybara, capybara-webkit.

@Kosmas
Copy link
Member

Kosmas commented Feb 5, 2014

@Loremaster have you tried to use the master branch and see if you get the same error?

@Loremaster
Copy link

I tried master branch of cucumber, and it didn't help.

I think that problem was in capybara-webkit. I didn't have much time to collect enough information (because i couldn't even get any stack's trace, a lot of tests just failed silently, without any message), but migration to the poltergeist helped a lot. At least, number of failing tests decreased.

On 05 ôåâð. 2014 ã., at 21:46, Kosmas Chatzimichalis [email protected] wrote:

@Loremaster have you tried to use the master branch and see if you get the same error?


Reply to this email directly or view it on GitHub.

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

Successfully merging this pull request may close these issues.

10 participants