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

rails test running twice in 3.3.1/not failing more than one test when it's supposed to #11

Open
JCattera opened this issue Jan 23, 2018 · 3 comments

Comments

@JCattera
Copy link

JCattera commented Jan 23, 2018

When I run the tests in Chapter 3.3.1, the console is showing that the tests are running twice for some reason.

Running via Spring preloader in process 4008
/usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:18: warning: already initialized constant Rails::Command::HELP_MAPPINGS
/usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/command.rb:18: warning: previous definition of HELP_MAPPINGS was here
Run options: --seed 61073

# Running:

Run options: --seed 61073

# Running:

....

Finished in 0.315740s, 6.3343 runs/s, 6.3343 assertions/s.

2 runs, 2 assertions, 0 failures, 0 errors, 0 skips


Finished in 0.315642s, 6.3363 runs/s, 6.3363 assertions/s.

This shouldn't be a problem, but when I try to do more than one failing test (for example, the test in 3.3.2 as well as changing "should get help" so that assert_response is looking for :error), it fails the first failing test and immediately exits instead of moving to the next test.

ec2-user:~/environment/sample_app2 (static-pages) $ rails test
Running via Spring preloader in process 4101
/usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:18: warning: already initialized constant Rails::Command::HELP_MAPPINGS
/usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/command.rb:18: warning: previous definition of HELP_MAPPINGS was here
Run options: --seed 63669

# Running:

Run options: --seed 63669

# Running:

FF

Failure:
StaticPagesControllerTest#test_should_get_help [/home/ec2-user/environment/sample_app2/test/controllers/static_pages_controller_test.rb:11]:
Expected response to be a <5XX: error>, but was a <200: OK>


/usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:70:in `method': undefined method `test_should_get_help' for class `Minitest::Result' (NameError)
        from /usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:70:in `format_rerun_snippet'
        from /usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:23:in `record'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:786:in `block in record'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:785:in `each'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:785:in `record'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:334:in `run_one_method'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:321:in `block (2 levels) in run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:320:in `each'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:320:in `block in run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:360:in `on_signal'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:347:in `with_info_handler'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:319:in `run'
        from /usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/test_unit/line_filtering.rb:9:in `run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:159:in `block in __run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:159:in `map'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:159:in `__run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:136:in `run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/minitest-5.11.1/lib/minitest.rb:63:in `block in autorun'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application.rb:171:in `serve'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
        from /usr/local/rvm/gems/ruby-2.4.1/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from -e:1:in `<main>'

This has happened both on my own local machine and on my Cloud9 environment, even when I tried redoing the first part of chapter 3 to make sure I hadn't installed anything incorrectly. Does this issue pop up for anybody else using the tutorial?

@JCattera
Copy link
Author

It turns out this is an issue having to do with minitest-reporters and how it interacts with minitest after Rails 5.1.3, discussed in more detail here. Until this issue is properly fixed, I'm going to do the tutorial without minitest-reporters since it's not absolutely essential, and I'd recommend that the guide either mention that issue or figure out a way to fix it.

@muhme
Copy link

muhme commented Feb 16, 2018

I have seen the same warnings:

hlu:~/environment/quote (master) $ rails test
/usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:18: warning: already initialized constant Rails::Command::HELP_MAPPINGS
/usr/local/rvm/gems/ruby-2.4.1@global/gems/railties-5.1.4/lib/rails/command.rb:18: warning: previous definition of HELP_MAPPINGS was here
Run options: --seed 33572
...

And as I do not like them too, I was trying to fix them. In the end it was fixed for me by updating rails gem from 5.1.4 to 5.1.5 in Cloud9 with:

hlu:~/environment/quote (master) $ rails -v
Rails 5.1.4
hlu:~/environment/quote (master) $ bundle update rails
...
hlu:~/environment/quote (master) $ rails -v
Rails 5.1.5

@gfsheppard
Copy link

As @JCattera points out this is an error with minitest and Rails, and will be fixed upstream at some point.
In the mean time, if you want to fix this so that guard works properly, add the following line to your Gemfile:
gem 'minitest', '5.10.1'

This will keep the minitest version that was working properly before this regression error appeared. I find it quite useful to have guard working in the background while doing the tutorial.

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

3 participants