我试图用RSpec中的Poltergeist驱动程序编写一个简单的Capybara规范。当测试失败时,似乎没有问题,但是当我期望通过测试时,我会得到以下错误:
~/.rbenv/versions/2.2.3/lib/
ruby/gems/2.2.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/errors.rb:17:in
`initialize': wrong number of arguments (0 for 2) (ArgumentError)我导航到错误所指示的代码行的位置:
class JSErrorItem
attr_reader :message, :stack
def initialize(message, stack)
@message = message
@stack = stack
end
def to_s
[message, stack].join("\n")
end
end 但是我找不到应该与这个构造函数交互的任何地方。
这是我正在写的规范
describe 'Sign Up', type: :feature do
it 'should allow user creation through the signup form' do
visit new_user_url host: 'http://localhost:3000'
within('.form') do
fill_in('user[username]', with: 'Example')
fill_in('user[password]', with: 'Password')
fill_in('user[password_confirmation]', with: 'Password')
find(".submit-button").click
puts page.body
expect(page).to have_content('Welcome')
User.last.destroy!
end
end
endputs page按预期的方式打印页面的内容,但是在错误发生后,规范中的其余行没有运行。奇怪的是,只有当我期望规范通过时,错误才会发生。当我期待一个失败的测试时,整个规范将毫无错误地运行。
我的规范助手设置如下:
RSpec.configure do |config|
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'capybara/dsl'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, time_out: 120, phantomjs_options: ['--ignore-ssl-errors=yes'], js_errors: false)
end
Capybara.configure do |c|
c.javascript_driver = :poltergeist
c.default_driver = :poltergeist
c.app_host = 'http://localhost:3000'
end
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end发布于 2016-05-21 19:23:19
我按照评论中的建议将Poltergeist升级到1.9,PhantomJS升级到2.1,并解决了这个问题。
https://stackoverflow.com/questions/37364693
复制相似问题