您好我在运行带有以下Gemfile的Rails 3.2.21应用程序:
group :test, :development do
gem "minitest-rails-capybara"
gem "capybara_minitest_spec"
gem 'factory_girl_rails'
gem 'turn'
gem 'guard'
gem 'guard-minitest'
gem 'poltergeist'
gem 'phantomjs', :require => 'phantomjs/poltergeist'
end
我有一个test / minitest_helper.rb这样的文件:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/autorun"
require "capybara/rails"
# require "active_support/testing/setup_and_teardown"
# MiniTest::Spec
class MiniTest::Spec
include FactoryGirl::Syntax::Methods
include Rails.application.routes.url_helpers
include Capybara::DSL
end
class IntegrationTest < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
register_spec_type(/test$/, self)
end
Turn.config.format = :outline
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
end
每当我尝试运行测试来测试HTML页面是否包含由某些javascript在test / features / order_test.rb中生成的某个单词
require 'minitest_helper'
describe "Simple Order Form" do
it "display selected file names after user selects files", js: true do
visit order_v3_path
page.must_have_content('drop')
end
end
它抱怨说&#34;它&#34;方法只需要0..1个参数
/Users/nik/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/minitest/spec.rb:201:in `it': wrong number of arguments (2 for 0..1) (ArgumentError)
如何找出问题所在?
提前致谢!
答案 0 :(得分:0)
根据Capybara,js:true应该在describe block中。
答案 1 :(得分:0)
您可以在特定测试中尝试使用js代替js: true do
。
Capybara.current_driver = :selenium