为什么我为Cucumber :: Rails :: World获取未定义的方法`click'?在Cucumber/Capybara的步骤

Iva*_*van 11 ruby-on-rails cucumber capybara

我可以得到其他的水豚方法,如访问,fill_in,选择等..工作.但不是点击

Given /^a no fee license called "([^"]*)"$/ do |arg1|
  @l = FactoryGirl.create(:license,
                      name: arg1)
end

When /^execute the license$/ do
  visit(license_path(@l))
  click('Execute License')
end
Run Code Online (Sandbox Code Playgroud)

错误:

Scenario: no fee license is executed                                 # features/visitor_no_fee_license.feature:14
    When I fill out the licensee info with valid info                  # features/step_definitions/licenses_steps.rb:21
    And execute the license                                            # features/step_definitions/licenses_steps.rb:35
      undefined method `click' for #<Cucumber::Rails::World:0x007feebad4dec8> (NoMethodError)
      ./features/step_definitions/licenses_steps.rb:37:in `/^execute the license$/'
      features/visitor_no_fee_license.feature:16:in `And execute the license'
Run Code Online (Sandbox Code Playgroud)

Iva*_*van 23

Capybara的DSL改变了.click_on如果您现在不知道它是链接还是按钮,请使用而不是单击.

https://github.com/jnicklas/capybara/blob/549e67336c712a1ef2119ce5ff64dbbc7542480f/lib/capybara/session.rb