2014-09-22 56 views

回答

0

我不得不配置在features/support/capybara_screenshot.rbcustom 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曾經是Cucumber::Ast::Background類的黃瓜1其具有限定的file_colon_line

但現在scenario黃瓜2不具有此filefile_colon_line再返回Cucumber::Core::Test::Case。但它有location,location.file,location.line,location.to_s