Closed Linuus closed 11 years ago
Running into the same problem with Rails 4. Doing what @Linuus suggested worked for me too.
I think this might be a problem with minitest-capybara 0.3. Try downgrading to 0.2 and see if that helps. I have some commits in that I'm waiting for before releasing a new version.
I had to require like this:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "capybara/rails"
require "capybara/rspec/matchers"
require "minitest/rails/capybara"
for solved this issue.
thanks @neokain it worked for me too..
I had a different error:
uninitialized constant MiniTest::Capybara::Assertions::Capybara (NameError)
Perhaps, do you also have the DEPRECATION warning?
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.
I still get it, even with that require order... weird.
Hi @allaire, I don't have DEPRECATION WARNING.
Make sure your Gemfile
is:
gem 'minitest-rails'
group :test do
gem "minitest-rails-capybara"
end
and full minitest_helper.rb
is:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "capybara/rails"
require "capybara/rspec/matchers"
require "minitest/rails/capybara"
class ActionDispatch::IntegrationTest
include Rails.application.routes.url_helpers
include Capybara::RSpecMatchers
include Capybara::DSL
end
the require
order is important, I try to reorder require
it make error.
If you still have DEPRECATION WARNING I don't know why.
This will be fixed in the release 0.10.0 coming later today. The gem minitest-capybara changed which causes this error. Moving forward minitest-capybara is going to provide assertions and expectations directly instead of relying on minitest-matchers and the Capybara::RSpecMatchers module. This likely won't make any difference to your tests, but I'm releasing a new point release just in case.
I don't know if this is related, but I keep having
# Running tests:
Finished tests in 0.000524s, 0.0000 tests/s, 0.0000 assertions/s.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
at the end of any rake task I type after upgrading.
@allaire Are you using minitest's spec DSL and do you have RSpec loaded? RSpec likes to stomp all over minitest's spec DSL.
I'm using an hybrid between minitest spec DSL, RSpec is not not loaded/in gemfile.lock
class OrganizationTest < ActiveSupport::TestCase
it 'must create a new organization' do
organization = FactoryGirl.create(:organization)
organization.name.wont_be_empty
end
end
Solved it with a bundle update, weird.
Please upgrade to 0.10 and let me know if you are still having problems. Thanks!
Works for me, but the README may need to be updated (e.g. the IntegrationTest instructions which will cause this same error without including "capybara/rspec/matchers", and also the references to minitest_helper.rb).
I've updated the README. You shouldn't need to include capybara/rspec/matchers as minitest-capybara no longer uses them. Thanks!
Hi
I got this error today:
The error originated from https://github.com/blowmage/minitest-rails-capybara/blob/master/lib/minitest/rails/capybara.rb#L11
So I had to require the matchers explicitly in my test_helper, like this:
So, adding the require to capybara.rb should fix the issue.
EDIT: Using Rails 4 btw