Capybara :: Webkit :: Driver的未定义方法accept_modal [英] Undefined method accept_modal for Capybara::Webkit::Driver

查看:84
本文介绍了Capybara :: Webkit :: Driver的未定义方法accept_modal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Rails应用中,我使用RSpec(带有Capybara Webkit)测试删除链接是否正常工作。

In a Rails app, I'm using RSpec (with Capybara Webkit) to test that a Delete link is working.

在Rails模板中,我具有:

In my Rails template I have:

<%= link_to 'Delete', movie_path(@movie), 
                      method: :delete, data: { confirm: 'Are you sure?' } %>

这是我的规范:

require 'rails_helper'

describe "Deleting a movie", js: true do
  it "destroys the movie and shows the movie listing without the deleted movie" do
    movie = Movie.create(movie_attributes)

    visit movie_path(movie)

    page.accept_confirm do
     click_link 'Delete'
    end

    expect(current_path).to eq(movies_path)
    expect(page).not_to have_text(movie.title)
  end
end

我收到错误:

NoMethodError:
   undefined method `accept_modal' for #<Capybara::Webkit::Driver:0x007febc2214908>

它使用的是正确的驱动程序(Webkit),但似乎找不到 accept_modal (必须由 page.accept_confirm 调用)。

It's using the right driver (Webkit) but it doesn't seem to find accept_modal (which must be called by page.accept_confirm).

I' m使用:

capybara (2.14.0)
capybara-webkit (1.1.0)
rails (5.1.1)
rspec (3.6.0)
rspec-rails (3.6.0)

请注意,使用以下内容将有效

click_link 'Delete'
page.driver.browser.accept_js_confirms

但我想了解为什么 accept_confirm 不会。

But I'd like to understand why accept_confirm does not.

推荐答案

您正在使用的capybara-webkit大大超出了日期(1.1.0于2013年12月实现),不支持统一的Capybara模态API(当capybara-webkit 1.1.0发布时不存在),并且没有从Capybara派生它的驱动程序类: :Driver :: Base,因此您不会收到 NotSupportedByDriverError 如果驱动程序尚未实现/支持某个功能,那么您现在会得到-更新到最新的capybara-webkit(如果要使用capybara 2.14.0+,则可能需要使用master分支,否则,您会卡在水豚2.13.x)

The capybara-webkit you are using is massively out of date (1.1.0 was realeased in December of 2013), didn't support the unified Capybara modal API (it didn't exist when capybara-webkit 1.1.0 was released), and didn't derive it's driver class from Capybara::Driver::Base, so you don't get the "NotSupportedByDriverError" you would get nowadays if a feature was not yet implemented/supported by a driver - update to the latest capybara-webkit (you may need to use the master branch if you want to use capybara 2.14.0+, otherwise you'll be stuck at capybara 2.13.x)

这篇关于Capybara :: Webkit :: Driver的未定义方法accept_modal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆