得到了未定义的方法`file_colon_line'在场景大纲中

时间:2014-09-22 23:10:32

标签: ruby-on-rails ruby cucumber

执行Scenario Outline后,我收到以下消息,并且方案失败。

示例:

  | ID  | mail           |
  | Abc | test1@mail.com |
  undefined method `file_colon_line' for #<Cucumber::Ast::OutlineTable::ExampleRow:0xbe09a88> (NoMethodError)
  | ABC | test2@mail.com |
  undefined method `file_colon_line' for #<Cucumber::Ast::OutlineTable::ExampleRow:0xbe09a60> (NoMethodError)

一些解决方案?

1 个答案:

答案 0 :(得分:0)

我在features/support/capybara_screenshot.rb中配置了custom screenshot filename,其中包含:

require 'capybara-screenshot'
require 'capybara-screenshot/cucumber'

Capybara.save_and_open_page_path = File.join(Integrator.root, 'tmp', 'failures')
Capybara::Screenshot.register_filename_prefix_formatter(:cucumber) do |scenario|
  # only works with Cucumber 1
  path = scenario.file_colon_line

  # also works with Cucumber 2
  path = scenario.location.to_s

  # ...
end

scenario曾经是黄瓜1的Cucumber::Ast::Backgroundscenario,其中file_colon_line已定义。

Cucumber::Core::Test::Case现在为黄瓜2返回file,而黄瓜2则不再有file_colon_linelocation。但它有location.filelocation.linelocation.to_sclear()