2017-07-19 82 views
0

希望有人可以帮助我这个。我做了搜索,但没有找到任何工作解决方案。无法加载这样的文件 - 水豚/ minitest

我已经开始为应用程序编写测试。我的集成测试运行良好,但后来我决定,因为我没有那么多的TDD驱动,因为我没有那么多时间来广泛测试我应该使用的所有应用层,而不是integration测试system测试,因为它们允许我像在浏览器中一样测试整个流程。

Rails 5.1.2

Gemfile (尝试了不同的变型中,只是水豚,然后与两个其他两个的组合)

gem 'minitest-rails' 
gem 'minitest-rails-capybara' 
gem 'capybara' 

test_helper.rb中
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 

application_system_test_case.rb
require "test_helper" 

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 
    driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 
end 

register_logins.rb

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) 

时错误完全跟踪中添加此:

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)>' 

,去上active_support depende ncies。

我曾尝试:

增加一,二,三test_helper.rb

group :development, :test do 
    gem 'minitest-rails' 
    gem 'minitest-capybara' 
    gem 'capybara' 
end 
'minitest-rails-capybara'

感谢

则:

require "capybara/rails" 
require "minitest/rails" 
require "minitest/rails/capybara" 

我宝石尝试

+0

你使用什么版本的水豚? –

+0

水豚(2.6.2)@ThomasWalpole –

+1

Rails 5.1系统测试需要至少2.13.0(不妨使用最新的(2.14。4),然后不再需要'minitest-capybara'或'minitest-rails'宝石 - 您需要'selenium-webdriver'作为默认设置,尽管 –

回答

3

文件capybara/minitest在版本2.13.0中添加到Capybara,这是Rails自Rails 5.1.0以来的系统测试所需的最低版本。升级到最新版本的水豚(2.14.4),并且不需要minitest-capybaraminitest-rails宝石。您还需要将“selenium-webdriver”gem添加到您的测试组。

此外,assert_response :success行在Capybara测试中无效,因为来自浏览器Capybara的HTTP响应代码通常不可用。

+0

谢谢,我添加了一条评论,如果你喜欢分享你对使用硒或无头像的看法,像poltergeist/cb-webkit,我会很感激 –

相关问题