ruby_raider 0.3.3 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07240bddaf0b3edae4d1d8202df31ac428c143941680f02fb51ea54a8b478d37
4
- data.tar.gz: 887a4fc52c2c5899cc5999292a1edd3a357d1ecedbac9dea691edb06f980c6f5
3
+ metadata.gz: aa0c6d643c3cde2157842b7627cd91377aab6e76d47f6f4136c14a6999eacedf
4
+ data.tar.gz: 94105992da2846eb8585d10d8b2c471418b6c8544ef2db948ea3a62c950006d8
5
5
  SHA512:
6
- metadata.gz: d4cf0f65241e104cb96ee22ee79e61a24e049cf834aed0ea0098ea801f64cabe0a037d3846f50c5d60148b50e4a2621fa06329f1a697ea2ee8750b6656c78a49
7
- data.tar.gz: ed34541a0df8cf638630d6db03617e1aff99a0fb7432378971ccd371242be91624c3940e94769acc9d5058194b27a946d40c15a955291ff2d5dee5de5d413e55
6
+ metadata.gz: 9ab37f89743262fa6fddfa3a72791e118bfb46f01596177cc488f9900207835ddf4478dd16f53d017ca58d1e11a72f7e4431a64035f25c8958949e1d2934bef9
7
+ data.tar.gz: ea715071ad366384139705627bf4ad0b5bee9665d3ee3dc4853debc735acea6ebc1ae32860188cf235bb62da47463bb97ac3c17d2509a99f76067fe4500270c5
@@ -0,0 +1,23 @@
1
+ name: Reek Code Review
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ reek:
7
+ name: runner / reek
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@f20f1eae726df008313d2e0d78c5e602562a1bcf
12
+ with:
13
+ ruby-version: head
14
+
15
+ - name: Check out code
16
+ uses: actions/checkout@v1
17
+
18
+ - name: reek
19
+ uses: reviewdog/action-reek@v1
20
+ with:
21
+ reek_version: gemfile
22
+ reporter: github-pr-review # Default is github-pr-check
23
+ fail_on_error: true
@@ -0,0 +1,27 @@
1
+ name: Rspec Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ "*" ]
6
+ pull_request:
7
+ branches: [ "*" ]
8
+
9
+ jobs:
10
+ build:
11
+ name: CI
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@f20f1eae726df008313d2e0d78c5e602562a1bcf
17
+ with:
18
+ ruby-version: head
19
+
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v3
22
+
23
+ - name: Install gems
24
+ run: bundle install
25
+
26
+ - name: Build and test with rspec
27
+ run: bundle exec rspec spec
@@ -0,0 +1,28 @@
1
+ name: Rubocop
2
+
3
+ on: [pull_request]
4
+
5
+ permissions:
6
+ contents: read
7
+ pull-requests: write
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: runner / rubocop
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@f20f1eae726df008313d2e0d78c5e602562a1bcf
16
+ with:
17
+ ruby-version: head
18
+
19
+ - name: Check out code
20
+ uses: actions/checkout@v1
21
+
22
+ - name: rubocop
23
+ uses: reviewdog/action-rubocop@v2
24
+ with:
25
+ rubocop_version: gemfile
26
+ rubocop_extensions: rubocop-rspec:gemfile
27
+ reporter: github-pr-review # Default is github-pr-check
28
+ fail_on_error: true
data/.rubocop.yml CHANGED
@@ -1,6 +1,8 @@
1
+ require: rubocop-rspec
2
+
1
3
  AllCops:
2
4
  Exclude:
3
5
  - './spec/*'
4
6
 
5
7
  Style/Documentation:
6
- Enabled: false
8
+ Enabled: false
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Ruby Raider
2
2
 
3
- This is a gem to make setup and start of UI automation projects easier
4
- You can find more information and updates on releases in : https://ruby-raider.com/
3
+ [![Gem Version](https://badge.fury.io/rb/ruby_raider.svg)](https://badge.fury.io/rb/ruby_raider)
4
+ [![Rubocop](https://github.com/RubyRaider/ruby_raider/actions/workflows/rspec.yml/badge.svg)](https://github.com/RubyRaider/ruby_raider/actions/workflows/rspec.yml)
5
+
6
+ This is a gem to make setup and start of UI automation projects easier.
7
+
8
+ You can find more information and updates on releases in : [https://ruby-raider.com/](https://ruby-raider.com/)
5
9
 
6
10
  Just do:
7
11
 
@@ -11,39 +15,52 @@ then do:
11
15
 
12
16
  **raider new [name_of_project]**
13
17
 
14
- and you will have a new project in the folder you are in
18
+ and you will have a new project in the folder you are in.
19
+
20
+ Currently we support:
21
+
22
+ * Generating a framework with Cucumber and Selenium
23
+
24
+ * Generating a framework with Rspec and Selenium
15
25
 
16
- Currently we only support:
26
+ * Generating a framework with Cucumber and Watir
17
27
 
18
- * Gerating a Selenium with both Cucumber and Rspec framework
19
- * Gerating a Watir with both Cucumber and Rspec framework
20
- * Generating an Appium project with Rspec and Cucumber on IOS
28
+ * Generating a framework with Rspec and Watir
21
29
 
22
- In order to run the appium tests, download the example [app](https://github.com/cloudgrey-io/the-app/releases/tag/v1.10.0)
30
+ * Generating a framework with Rspec and Appium for IOS
23
31
 
24
- This works in all the platforms (Tested on Mac OS, Linux and Windows)
32
+ * Generating a framework with Cucumber and Appium for IOS
33
+
34
+ In order to run the Appium tests, download the example [app](https://github.com/cloudgrey-io/the-app/releases/tag/v1.10.0).
35
+
36
+ This works in all the platforms (Tested on Mac OS, Linux and Windows).
25
37
 
26
38
  **Ruby raider provides the following list of commands**
27
39
  ```
28
- raider browser [BROWSER] # Sets the default browser for a project
40
+ Commands:
41
+ raider browser [BROWSER] # Sets the default browser for a project
42
+
43
+ raider browser_options [OPTIONS] # Sets the browser options for the project
29
44
 
30
- raider feature [FEATURE_NAME] # Creates a new feature
45
+ raider feature [FEATURE_NAME] # Creates a new feature
46
+
47
+ raider help [COMMAND] # Describes available commands or one specific command
31
48
 
32
- raider help [COMMAND] # Describe available commands or one specific command
49
+ raider helper [HELPER_NAME] # Creates a new helper
33
50
 
34
- raider helper [HELPER_NAME] # Creates a new helper
51
+ raider new [PROJECT_NAME] # Creates a new framework based on settings picked
35
52
 
36
- raider new [PROJECT_NAME] # Creates a new framework based on settings picked
53
+ raider page [PAGE_NAME] # Creates a new page object
37
54
 
38
- raider page [PAGE_NAME] # Creates a new page object
55
+ raider path [PATH] # Sets the default path for scaffolding
39
56
 
40
- raider path [PATH] # Sets the default path for scaffolding
57
+ raider raid # Runs all the tests in a project
41
58
 
42
- raider raid # It runs all the tests in a project
59
+ raider scaffold [SCAFFOLD_NAME] # Generates everything needed to start automating
43
60
 
44
- raider spec [SPEC_NAME] # Creates a new spec
61
+ raider spec [SPEC_NAME] # Creates a new spec
45
62
 
46
- raider url [URL] # Sets the default url for a project
63
+ raider url [URL] # Sets the default url for a project
47
64
  ```
48
65
 
49
66
  It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
@@ -57,4 +74,4 @@ raider path [PATH_NAME] --spec or -s
57
74
  raider path [PATH_NAME] --helper or -h
58
75
  ```
59
76
 
60
- If you don't specify an option path will assume you want to change the default path for pages
77
+ If you don't specify an option, path will assume you want to change the default path for pages.
data/Rakefile CHANGED
@@ -1,15 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'lib/ruby_raider'
4
+ require_relative 'lib/commands/scaffolding_commands'
4
5
 
5
- desc 'Create a new test projects'
6
- task :new, [:name] do |_t, args|
6
+ desc 'Creates a new test project'
7
+ task :new do
7
8
  RubyRaider.start
8
- RubyRaider.new(args.name)
9
9
  end
10
10
 
11
- desc 'Create a page'
12
- task :page, [:name] do |_t, args|
13
- RubyRaider.start
14
- RubyRaider.page(args.page)
11
+ desc 'Creates a page'
12
+ task :page, [:name, :path] do |_t, args|
13
+ ScaffoldingCommands.new.invoke(:page, nil, %W[:#{args.name} --path #{args.path}])
14
+ end
15
+
16
+ desc 'Sets a browser'
17
+ task :browser, [:type, :options] do |_t, args|
18
+ ScaffoldingCommands.new.invoke(:browser, nil, %W[:#{args.type} --opts #{args.options}])
15
19
  end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../generators/menu_generator'
4
+ require_relative '../scaffolding/scaffolding'
5
+ require_relative '../commands/utility_commands'
6
+
7
+ class ScaffoldingCommands < UtilityCommands
8
+ desc 'new [PROJECT_NAME]', 'Creates a new framework based on settings picked'
9
+
10
+ def new(project_name)
11
+ MenuGenerator.new(project_name).generate_choice_menu
12
+ end
13
+
14
+ map '-n' => 'new'
15
+
16
+ desc 'page [PAGE_NAME]', 'Creates a new page object'
17
+ option :path,
18
+ type: :string, required: false, desc: 'The path where your page will be created', aliases: '-p'
19
+ option :delete,
20
+ type: :boolean, required: false, desc: 'This will delete the selected page', aliases: '-d'
21
+
22
+ def page(name)
23
+ path = options[:path] || load_config_path('page')
24
+ if options[:delete]
25
+ Scaffolding.new([name, path]).delete_class
26
+ else
27
+ Scaffolding.new([name, path]).generate_class
28
+ end
29
+ end
30
+
31
+ map '-pg' => 'page'
32
+
33
+ desc 'feature [FEATURE_NAME]', 'Creates a new feature'
34
+ option :path,
35
+ type: :string, required: false, desc: 'The path where your feature will be created', aliases: '-p'
36
+ option :delete,
37
+ type: :boolean, required: false, desc: 'This will delete the selected feature', aliases: '-d'
38
+
39
+ def feature(name)
40
+ path = options[:path] || load_config_path('feature')
41
+ if options[:delete]
42
+ Scaffolding.new([name, path]).delete_feature
43
+ else
44
+ Scaffolding.new([name, path]).generate_feature
45
+ end
46
+ end
47
+
48
+ map '-f' => 'feature'
49
+
50
+ desc 'spec [SPEC_NAME]', 'Creates a new spec'
51
+ option :path,
52
+ type: :string, required: false, desc: 'The path where your spec will be created', aliases: '-p'
53
+ option :delete,
54
+ type: :boolean, required: false, desc: 'This will delete the selected spec', aliases: '-d'
55
+
56
+ def spec(name)
57
+ path = options[:path] || load_config_path('spec')
58
+ if options[:delete]
59
+ Scaffolding.new([name, path]).delete_spec
60
+ else
61
+ Scaffolding.new([name, path]).generate_spec
62
+ end
63
+ end
64
+
65
+ map '-s' => 'spec'
66
+
67
+ desc 'helper [HELPER_NAME]', 'Creates a new helper'
68
+ option :path,
69
+ type: :string, required: false, desc: 'The path where your helper will be created', aliases: '-p'
70
+ option :delete,
71
+ type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d'
72
+
73
+ def helper(name)
74
+ path = options[:path] || load_config_path('helper')
75
+ if options[:delete]
76
+ Scaffolding.new([name, path]).delete_helper
77
+ else
78
+ Scaffolding.new([name, path]).generate_helper
79
+ end
80
+ end
81
+
82
+ map '-h' => 'helper'
83
+
84
+ desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
85
+
86
+ def scaffold(name)
87
+ if Pathname.new('spec').exist? && !Pathname.new('features').exist?
88
+ Scaffolding.new([name, load_config_path('spec')]).generate_spec
89
+ elsif Pathname.new('features').exist?
90
+ Scaffolding.new([name, load_config_path('feature')]).generate_feature
91
+ end
92
+ Scaffolding.new([name, load_config_path('page')]).generate_class
93
+ end
94
+
95
+ map '-sf' => 'scaffold'
96
+
97
+ desc 'config', 'Creates configuration file'
98
+ option :delete,
99
+ type: :boolean, required: false, desc: 'This will delete the config file', aliases: '-d'
100
+
101
+ def config
102
+ if options[:delete]
103
+ Scaffolding.new.delete_config
104
+ else
105
+ Scaffolding.new.generate_config
106
+ end
107
+ end
108
+
109
+ map '-c' => 'config'
110
+
111
+ no_commands do
112
+ def load_config_path(type)
113
+ YAML.load_file('config/config.yml')["#{type}_path"] if YAML.load_file('config/config.yml')
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require_relative '../utilities/utilities'
5
+
6
+ class UtilityCommands < Thor
7
+ desc 'path [PATH]', 'Sets the default path for scaffolding'
8
+ option :feature,
9
+ type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
10
+ option :helper,
11
+ type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
12
+ option :spec,
13
+ type: :boolean, required: false, desc: 'The default path for your specs', aliases: '-s'
14
+
15
+ def path(default_path)
16
+ type = options.empty? ? 'page' : options.keys.first
17
+ Utilities.new.send("#{type}_path=", default_path)
18
+ end
19
+
20
+ map '-p' => 'path'
21
+
22
+ desc 'url [URL]', 'Sets the default url for a project'
23
+
24
+ def url(default_url)
25
+ Utilities.new.url = default_url
26
+ end
27
+
28
+ map '-u' => 'url'
29
+
30
+ desc 'browser [BROWSER]', 'Sets the default browser for a project'
31
+ option :opts,
32
+ type: :array, required: false, desc: 'The options you want your browser to run with', aliases: '-o'
33
+ option :delete,
34
+ type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
35
+
36
+ def browser(default_browser = nil)
37
+ Utilities.new.browser = default_browser if default_browser
38
+ browser_options(options[:opts]) if options[:opts] || options[:delete]
39
+ end
40
+
41
+ map '-b' => 'browser'
42
+
43
+ desc 'browser_options [OPTIONS]', 'Sets the browser options for the project'
44
+ option :delete,
45
+ type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
46
+
47
+ def browser_options(*opts)
48
+ Utilities.new.browser_options = opts unless opts.empty?
49
+ Utilities.new.delete_browser_options if options[:delete]
50
+ end
51
+
52
+ map '-bo' => 'browser_options'
53
+
54
+ desc 'raid', 'It runs all the tests in a project'
55
+
56
+ def raid
57
+ Utilities.new.run
58
+ end
59
+
60
+ map '-r' => 'raid'
61
+
62
+ desc 'config', 'Creates a new config file'
63
+ option :path,
64
+ type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
65
+ option :delete,
66
+ type: :boolean, required: false, desc: 'This will delete the selected config file', aliases: '-d'
67
+ end
@@ -8,64 +8,79 @@ require_relative 'helper_generator'
8
8
  require_relative 'rspec_generator'
9
9
 
10
10
  class MenuGenerator
11
- class << self
12
- def generate_choice_menu(project_name)
13
- @cli = HighLine.new
14
- @cli.choose do |menu|
15
- menu.prompt = 'Please select your automation framework'
16
- menu.choice('Selenium') { choose_test_framework('selenium', project_name) }
17
- menu.choice('Watir') { choose_test_framework('watir', project_name) }
18
- menu.choice('Appium') { choose_test_framework('appium', project_name) }
19
- menu.choice('Quit') { exit }
20
- end
11
+ attr_reader :cli, :name, :generators
12
+
13
+ def initialize(project_name)
14
+ @cli = HighLine.new
15
+ @name = project_name
16
+ @generators = %w[Automation Common Helpers]
17
+ end
18
+
19
+ def generate_choice_menu
20
+ @cli.choose do |menu|
21
+ menu.prompt = 'Please select your automation framework'
22
+ menu.choice('Selenium') { choose_test_framework('selenium') }
23
+ menu.choice('Watir') { choose_test_framework('watir') }
24
+ menu.choice('Appium') { choose_test_framework('appium') }
25
+ menu.choice('Quit') { exit }
21
26
  end
27
+ end
28
+
29
+ def choose_test_framework(automation)
30
+ system('clear') || system('cls')
31
+ sleep 0.3
32
+ automation = automation == 'appium' ? choose_mobile_platform : automation
33
+ select_test_framework(automation)
34
+ end
35
+
36
+ def set_framework(automation, framework)
37
+ add_generator framework.capitalize
38
+ generators.each { |generator| invoke_generator(automation, framework, generator) }
39
+ system "cd #{name} && gem install bundler && bundle install"
40
+ end
22
41
 
23
- def choose_test_framework(automation, project_name)
24
- system('clear') || system('cls')
25
- sleep 0.3
26
- automation = automation == 'appium' ? choose_mobile_platform : automation
27
- framework = ''
28
- @cli.choose do |menu|
29
- menu.prompt = 'Please select your test framework'
30
- menu.choice('Rspec') do
31
- framework = 'rspec'
32
- set_framework(automation, framework, project_name)
33
- end
34
- menu.choice('Cucumber') do
35
- framework = 'cucumber'
36
- set_framework(automation, framework, project_name)
37
- end
38
- menu.choice('Quit') { exit }
39
- end
40
- @cli.say("You have chosen to use #{framework} with #{automation}")
42
+ def choose_mobile_platform
43
+ @cli.choose do |menu|
44
+ menu.prompt = 'Please select your mobile platform'
45
+ menu.choice('iOS') { 'appium_ios' }
46
+ error_handling(menu, 'Android')
47
+ error_handling(menu, 'Cross Platform')
48
+ menu.choice('Quit') { exit }
41
49
  end
50
+ end
51
+
52
+ protected
42
53
 
43
- def set_framework(automation, framework, project_name)
44
- if framework == 'rspec'
45
- RspecGenerator.new([automation, framework, project_name]).invoke_all
46
- else
47
- CucumberGenerator.new([automation, framework, project_name]).invoke_all
48
- end
49
- AutomationGenerator.new([automation, framework, project_name]).invoke_all
50
- CommonGenerator.new([automation, framework, project_name]).invoke_all
51
- HelpersGenerator.new([automation, framework, project_name]).invoke_all
52
- system "cd #{project_name} && gem install bundler && bundle install"
54
+ def add_generator(*opts)
55
+ opts.each { |opt| @generators.push opt }
56
+ end
57
+
58
+ private
59
+
60
+ def framework_choice(invoker, framework, automation_type)
61
+ invoker.choice(framework) do
62
+ set_framework(automation_type, framework.downcase)
63
+ @cli.say("You have chosen to use #{framework} with #{automation_type}")
53
64
  end
65
+ end
54
66
 
55
- def choose_mobile_platform
56
- @cli.choose do |menu|
57
- menu.prompt = 'Please select your mobile platform'
58
- menu.choice('iOS') { 'appium_ios' }
59
- menu.choice('Android') do
60
- pp 'Android appium is coming soon. Thank you for the interest'
61
- exit
62
- end
63
- menu.choice('Cross Platform') do
64
- pp 'Cross platform appium is coming soon. Thank you for the interest'
65
- exit
66
- end
67
- menu.choice('Quit') { exit }
68
- end
67
+ def error_handling(invoker, platform)
68
+ invoker.choice(platform) do
69
+ pp "#{platform} appium is coming soon. Thank you for the interest"
70
+ exit
69
71
  end
70
72
  end
73
+
74
+ def select_test_framework(automation)
75
+ @cli.choose do |menu|
76
+ menu.prompt = 'Please select your test framework'
77
+ framework_choice(menu, 'Rspec', automation)
78
+ framework_choice(menu, 'Cucumber', automation)
79
+ menu.choice('Quit') { exit }
80
+ end
81
+ end
82
+
83
+ def invoke_generator(automation, framework, generator)
84
+ Object.const_get("#{generator}Generator").new([automation, framework, name]).invoke_all
85
+ end
71
86
  end
@@ -25,25 +25,28 @@ This works in all the platforms (Tested on Mac OS, Linux and Windows)
25
25
 
26
26
  **Ruby raider provides the following list of commands**
27
27
  ```
28
- raider browser [BROWSER] # Sets the default browser for a project
28
+ Commands:
29
+ raider browser [BROWSER] # Sets the default browser for a project
29
30
 
30
- raider feature [FEATURE_NAME] # Creates a new feature
31
+ raider feature [FEATURE_NAME] # Creates a new feature
31
32
 
32
- raider help [COMMAND] # Describe available commands or one specific command
33
+ raider help [COMMAND] # Describe available commands or one specific command
33
34
 
34
- raider helper [HELPER_NAME] # Creates a new helper
35
+ raider helper [HELPER_NAME] # Creates a new helper
35
36
 
36
- raider new [PROJECT_NAME] # Creates a new framework based on settings picked
37
+ raider new [PROJECT_NAME] # Creates a new framework based on settings picked
37
38
 
38
- raider page [PAGE_NAME] # Creates a new page object
39
+ raider page [PAGE_NAME] # Creates a new page object
39
40
 
40
- raider path [PATH] # Sets the default path for scaffolding
41
+ raider path [PATH] # Sets the default path for scaffolding
41
42
 
42
- raider raid # It runs all the tests in a project
43
+ raider raid # It runs all the tests in a project
43
44
 
44
- raider spec [SPEC_NAME] # Creates a new spec
45
+ raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
45
46
 
46
- raider url [URL] # Sets the default url for a project
47
+ raider spec [SPEC_NAME] # Creates a new spec
48
+
49
+ raider url [URL] # Sets the default url for a project
47
50
  ```
48
51
 
49
52
  It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
@@ -1,8 +1,8 @@
1
1
  <% case automation
2
2
  when 'selenium' -%>
3
- <%= ERB.new(File.read(File.expand_path('./partials/selenium_appium_env.tt', __dir__))).result(binding).strip! -%>
3
+ <%= ERB.new(File.read(File.expand_path('./partials/selenium_appium_env.tt', __dir__))).result(binding) %>
4
4
  <% when 'watir' -%>
5
- <%= ERB.new(File.read(File.expand_path('./partials/watir_env.tt', __dir__))).result(binding).strip! -%>
5
+ <%= ERB.new(File.read(File.expand_path('./partials/watir_env.tt', __dir__))).result(binding) %>
6
6
  <% else -%>
7
- <%= ERB.new(File.read(File.expand_path('./partials/appium_env.tt', __dir__))).result(binding).strip! -%>
7
+ <%= ERB.new(File.read(File.expand_path('./partials/appium_env.tt', __dir__))).result(binding) %>
8
8
  <% end -%>
@@ -1,11 +1,13 @@
1
1
  require_relative '../../helpers/driver_helper'
2
2
 
3
+ include Raider::DriverHelper
4
+
3
5
  Before do
4
- @driver = Raider::DriverHelper.new_driver
6
+ new_driver
5
7
  end
6
8
 
7
9
  After do |scenario|
8
- @driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
10
+ driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
9
11
  Raider::AllureHelper.add_screenshot(scenario.name)
10
- @driver.quit
11
- end
12
+ driver.quit
13
+ end
@@ -1,12 +1,13 @@
1
1
  require_relative '../../helpers/browser_helper'
2
2
 
3
+ include Raider::BrowserHelper
4
+
3
5
  Before do
4
- Raider::AllureHelper.configure
5
- @browser = Raider::BrowserHelper.new_browser
6
+ new_browser
6
7
  end
7
8
 
8
9
  After do |scenario|
9
- @browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
10
+ browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
10
11
  Raider::AllureHelper.add_screenshot(scenario.name)
11
- @browser.quit
12
- end
12
+ browser.quit
13
+ end
@@ -16,7 +16,7 @@ module Raider
16
16
  def add_screenshot(screenshot_name)
17
17
  Allure.add_attachment(
18
18
  name: name,
19
- source: "File.open(allure-results/screenshots/#{screenshot_name}.png)",
19
+ source: File.open("allure-results/screenshots/#{screenshot_name}.png"),
20
20
  type: Allure::ContentType::PNG,
21
21
  test_case: true
22
22
  )
@@ -7,13 +7,13 @@ require 'webdrivers'
7
7
 
8
8
  module Raider
9
9
  module BrowserHelper
10
- class << self
11
10
  attr_reader :browser
12
11
 
13
- def new_browser(options = {})
14
- browser = YAML.load_file('config/config.yml')['browser'].to_sym
15
- @browser = Watir::Browser.new(browser, options: options)
12
+ def new_browser(*args)
13
+ @config = YAML.load_file('config/config.yml')
14
+ browser = @config['browser'].to_sym
15
+ args = args.empty? ? @config['browser_options'] : args
16
+ @browser = Watir::Browser.new(browser, options: { args: args })
16
17
  end
17
- end
18
18
  end
19
19
  end