#Setup
BeforeAll do
Capybara.current_session.visit '/'
end
Before do
# Code that runs before each scenario is executed.
end
#Teardown
After do |scenario|
if (scenario.failed?)
time = Time.now.strftime('%Y_%m_%d_%H_%M_%S_')
name_of_scenario = time + scenario.name.gsub(/\s+/, "_").gsub("/", "_")
page.driver.browser.save_screenshot("html-reports/#{name_of_scenario}.png")
attach("html-reports/#{name_of_scenario}.png", "image/png")
visit '/logout/'
else
unless scenario.source_tag_names.include?('@no_logout')
visit '/logout/'
end
end
end
at_exit do
# Code that runs after all features have finished, just before the Cucumber process exits. For cleaning up test data.
end