In addition to minitest + capybara, I am actually also trying to + factory_girl, but I haven't gotten there yet.
Before I get to my primary question, I first want to ask a question regarding minitest-rails docs (GitHub/README.rdoc). The "Configure" section says "Add minitest-rails to the Gemfile", but doing so would include the gem in production. Should the gem better be added to a :development and :test group? (Obviously :test so we can actually test, but also in :development so its available via rake -- this latter point actually tripped me up!).
Now to my main issue: I am trying to set up minitest + capybara, following the GitHub docs, but I am getting tripped up very early on.
First I started by installing minitest-rails because the minitest-rails-capybara docs (GitHub/README.rdoc) told me so. After adding minitest-rails to a :development and :test group in Gemfile (and running `bundle`), the "Configure" section of minitest-rails docs (GitHub/README.rdoc) says "Next run the installation generator with the following: `rails generate mini_test:install`. This will add the `test_helper.rb` file to the `test` directory." And indeed, /test/test_help.rb is added. This file contains:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
require "minitest/rails/capybara"
# Uncomment for awesome colorful output
# require "minitest/pride"
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
Next, I go to set up minitest-rails-capybara. I add minitest-rails-capybara to the :test group in Gemfile, again, as per the docs. The docs then tell me to "Add the following to your minitest_helper.rb file to the `test` directory."
require "minitest/rails/capybara"
But I don't have this file, as minutes before I just created a rails app via `rails new demo --skip-test-unit`. So I create this file (test/minitest_helper.rb) from scratch:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/rails/capybara"
Next I continue with the Usage part of the instructions and run the feature generator:
rails generate mini_test:feature CanAccessHome
Then I run `ruby -Itest test/features/can_access_home_test.rb` and get:
DEPRECATION WARNING: It looks like you are using test helper generated by an older version of minitest-rails. Please upgrade your test_helper by following the instructions below. Support for this older helper will removed when minitest-rails reaches 1.0 release.
And those wiki docs tell me that the use of test/minitest_helper.rb has been discontinued, and that I should rename it to test/test_helper.rb -- but that seems weird because test/test_helper.rb was just created by a few minutes ago by `rails generate mini_test:install`. Should the docs be updated? And should minitest-rails-capybara's feature generator be generating a feature test that requires test_helper.rb?
If YES to all of the above, I would like to "shotgun" updating the docs and generator templates. Most of the minitest-rails-capybara changes are as follows, and unless you say otherwise, I know what needs to be changed in the minitest-rails docs.
-bash> grep -HnR minitest_helper *
README.rdoc:27:Add the following to your <tt>minitest_helper.rb</tt> file to the <tt>test</tt> directory.
README.rdoc:41: require "minitest_helper"
README.rdoc:56: require "minitest_helper"
README.rdoc:65:If you want Capybara within your integration tests, add the following to your <tt>minitest_helper.rb</tt> file:
lib/generators/mini_test/feature/templates/feature_spec.rb:1:require "minitest_helper"
lib/generators/mini_test/feature/templates/feature_test.rb:1:require "minitest_helper"
If NO anywhere, please explain. Also, once you explain, I still want to shotgun making the changes. Just let me know if you want me to or not.
Thanks.