Capybara feature tests not running

358 views
Skip to first unread message

Linus Pettersson

unread,
Feb 12, 2013, 2:34:12 PM2/12/13
to minites...@googlegroups.com
Hi

I've installed minitest-rails and minitest-rails-capybara. I have:
require "minitest/rails/capybara"
in my minitest_helper.rb

I generated a feature test with:
rails generate mini_test:feature UserLogin

But when I run "rake test" it doesn't run this test. Shouldn't it do that?

Do I have to do anything else to run capybara tests?

Linus Pettersson

unread,
Feb 12, 2013, 3:23:30 PM2/12/13
to minites...@googlegroups.com
Also, I'm using Rails 3.2.12.

Linus Pettersson

unread,
Feb 12, 2013, 3:27:30 PM2/12/13
to minites...@googlegroups.com
If I rename the test/features folder to integration it works. :-/

Mike Moore

unread,
Feb 12, 2013, 3:35:56 PM2/12/13
to minites...@googlegroups.com
Good questions. To run all the features tests, run the following rake task:

    $ rake minitest:features

To add the features tests to the default testing task, the one that `rake`, `rake test`, and `rake minitest` run, add the following to bottom of your Rakefile:

    MiniTest::Rails::Testing.default_tasks < "features"

I'll update the README with this information.


--
-- You received this message because you are subscribed to the Google Groups minitest-rails group. To post to this group, send email to minites...@googlegroups.com. To unsubscribe from this group, send email to minitest-rail...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/minitest-rails?hl=en
---
You received this message because you are subscribed to the Google Groups "minitest-rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minitest-rail...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Linus Pettersson

unread,
Feb 12, 2013, 3:48:37 PM2/12/13
to minites...@googlegroups.com
Thank you! Works great.

But you have a typo. You missed one <   :)

MiniTest::Rails::Testing.default_tasks << "features"

Linus Pettersson

unread,
Feb 13, 2013, 10:50:32 AM2/13/13
to minites...@googlegroups.com
Also, you need to wrap it with
if Rails.env != "production"
....
end

or something. Otherwise it fails in production since MiniTest is not available.



Den tisdagen den 12:e februari 2013 kl. 21:35:56 UTC+1 skrev Mike Moore:

Mike Moore

unread,
Feb 13, 2013, 6:15:19 PM2/13/13
to minites...@googlegroups.com
On Wed, Feb 13, 2013 at 8:50 AM, Linus Pettersson <linus.pe...@gmail.com> wrote:
Also, you need to wrap it with
if Rails.env != "production"
....
end

or something. Otherwise it fails in production since MiniTest is not available.

Oh yes. I used to recommend that minitest-rails was in the development and test groups in your Gemfile. I don't recommend that anymore, partially because of this.

Mathieu Allaire

unread,
Apr 1, 2013, 8:07:16 PM4/1/13
to minites...@googlegroups.com
May I ask why it's discouraged to have minitest-rails in group :development, :test? All my test stuff lives there, so I would rather have it in that group :)

Mike Moore

unread,
Apr 1, 2013, 8:20:25 PM4/1/13
to minites...@googlegroups.com
On Mon, Apr 1, 2013 at 6:07 PM, Mathieu Allaire <mathieu...@gmail.com> wrote:
May I ask why it's discouraged to have minitest-rails in group :development, :test? All my test stuff lives there, so I would rather have it in that group :)

You can do whatever you want. If you want minitest-rails to be in those groups then you can do that. :)

The reason I don't recommend it anymore is that minitest-rails is very light on startup. All it does is register itself as the testing framework and add the rake tasks. It doesn't load the testing libraries. (Unlike rspec-rails... ಠ̯ಠ) The default testing engine also works this way, and is not in just the development and test groups.

An additional benefit is that adding additional tests to the default testing task is simpler as well. So instead of having this in your Rakefile:

MiniTest::Rails::Testing.default_tasks << "features" if (Rails.env.development? || Rails.env.test?)

You can simply say this:

MiniTest::Rails::Testing.default_tasks << "features"

So to recap, requiring minitest-rails outside of the development/test groups adds no additional overhead to your application, makes your Gemfile simpler, and makes your Rakefile simpler.

Hope that helps,
~Mike

Reply all
Reply to author
Forward
0 new messages