Reputation: 2290
hope somebody can help me with this. I did search but haven't found any working solution.
I've started writing test for an app. My integration tests run fine, but then I decided that since I'm not that much of TDD driven and since I don't have that much time right now to extensively test all layers of the app that I should use instead of integration
tests system
tests, because they allow me to test the full flow as if in a browser.
Rails 5.1.2
Gemfile
(tried different variations, just capybara, then with combinations of both the other two)
gem 'minitest-rails'
gem 'minitest-rails-capybara'
gem 'capybara'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
EMPTY_NEW_USER = {
email: '',
first_name: '',
last_name: '',
username: '',
password: ''
}
EXISTING_USER = {
email: '****',
first_name: 'John',
last_name: 'Doe',
username: '',
password: 'testingpass',
password_confirmation: 'testingpass'
}
# Add more helper methods to be used by all tests here...
end
require "test_helper"
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
end
require "application_system_test_case"
class RegisterLoginsTest < ApplicationSystemTestCase
test 'full login flow' do
visit root_url
assert_response :success
find('.email_link').click
end
end
rake test:system
LoadError: cannot load such file -- capybara/minitest
/Users/mnussbaumer/code/dvouch/test/application_system_test_case.rb:3:in `<top (required)>'
/Users/mnussbaumer/code/dvouch/test/system/register_logins_test.rb:1:in `<top (required)>'
Tasks: TOP => test:system
(See full trace by running task with --trace)
The full trace adds this:
LoadError: cannot load such file -- capybara/minitest
/Users/mnussbaumer/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/Users/mnussbaumer/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'
/Users/mnussbaumer/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/mnussbaumer/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/Users/mnussbaumer/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-5.1.2/lib/action_dispatch/system_test_case.rb:2:in `<top (required)>'
/Users/mnussbaumer/code/dvouch/test/application_system_test_case.rb:3:in `<top (required)>'
and goes on on active_support dependencies.
What I have tried:
Adding one, two and three to test_helper.rb
:
require "capybara/rails"
require "minitest/rails"
require "minitest/rails/capybara"
I tried with gems:
group :development, :test do
gem 'minitest-rails'
gem 'minitest-capybara'
gem 'capybara'
end
then with 'minitest-rails-capybara'
Thanks
Upvotes: 0
Views: 1343
Reputation: 49870
The file capybara/minitest
was added to Capybara in version 2.13.0, which is the minimum version Rails requires for its system tests since Rails 5.1.0. Upgrade to the latest version of Capybara (2.14.4) and there should be no need for the minitest-capybara
or minitest-rails
gems. You will need to also add the 'selenium-webdriver' gem to your test group.
Additionally the assert_response :success
line is't valid in Capybara tests because the HTTP response code from the browser Capybara is using isn't generally available.
Upvotes: 5