<%- if automation == 'sparkling_ios' -%> # frozen_string_literal: true require 'rspec' require 'tmpdir' require_relative 'allure_helper' require_relative 'driver_helper' require 'sparkling_watir' module SpecHelper AllureHelper.configure RSpec.configure do |config| config.formatter = AllureHelper.formatter config.include(DriverHelper) config.before(:each) do app end config.after(:each) do |example| example_name = example.description Dir.mktmpdir do |temp_folder| screenshot = app.screenshot.save("#{temp_folder}/#{example_name}.png") AllureHelper.add_screenshot(example_name, screenshot) end app.close end end end <%- else -%> # frozen_string_literal: true <%- if axe? %> require 'axe-rspec' <%- end -%> require 'rspec' require 'tmpdir' require_relative 'allure_helper' <%- if automation == 'watir' -%> require_relative 'browser_helper' <%- else -%> require_relative 'driver_helper' <%- end -%> module SpecHelper AllureHelper.configure RSpec.configure do |config| config.formatter = AllureHelper.formatter <% if automation == 'watir' %>config.include(BrowserHelper)<% else %>config.include(DriverHelper)<% end %> <%- if %w[android ios cross_platform].include? automation -%> config.before(:each) do driver.start_driver end <%- elsif automation == 'selenium' -%> config.before(:each) do driver.manage.window.maximize end <%- elsif automation == 'watir' -%> config.before(:each) do browser.window.maximize end <%- end -%> config.after(:each) do |example| example_name = example.description Dir.mktmpdir do |temp_folder| <%= ERB.new(File.read(File.expand_path('./partials/screenshot.tt', __dir__)), trim_mode: '-').result(binding).strip! %> AllureHelper.add_screenshot(example_name, screenshot) end <%= ERB.new(File.read(File.expand_path('./partials/quit_driver.tt', __dir__)), trim_mode: '-').result(binding).strip! %> end end end <%- end -%>