Class: EnvTemplate

Inherits:
Template show all
Defined in:
lib/generators/templates/cucumber/env_template.rb

Instance Method Summary collapse

Methods inherited from Template

#initialize, #parsed_body

Constructor Details

This class inherits a constructor from Template

Instance Method Details

#bodyObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/templates/cucumber/env_template.rb', line 4

def body

  if @automation == 'watir'
    helper = 'helpers/browser_helper'
    browser = 'Raider::BrowserHelper.new_browser'
    get_browser = 'browser = Raider::BrowserHelper.new_browser'
    screenshot = 'browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")'
    quit = 'browser.quit'
  else
    helper = 'helpers/driver_helper'
    browser = 'Raider::DriverHelper.new_driver'
    get_browser = 'driver = Raider::DriverHelper.driver'
    screenshot = 'driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")'
    quit = 'driver.quit'
  end

  <<~EOF
    require 'active_support/all'
    require_relative 'helpers/allure_helper'
    require_relative '#{helper}'

    Before do
        Raider::AllureHelper.configure
        #{browser}
    end

    After do |scenario|
     #{get_browser}
      #{screenshot}
      Raider::AllureHelper.add_screenshot(scenario.name)
      #{quit}
    end
  EOF
end