ruby_raider 0.3.4 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/reek.yml +23 -0
- data/.github/workflows/rspec.yml +27 -0
- data/.github/workflows/rubocop.yml +28 -0
- data/.reek.yml +7 -1
- data/.rubocop.yml +88 -1
- data/README.md +27 -13
- data/Rakefile +11 -7
- data/lib/commands/scaffolding_commands.rb +116 -0
- data/lib/commands/utility_commands.rb +67 -0
- data/lib/generators/menu_generator.rb +60 -54
- data/lib/generators/templates/cucumber/env.tt +3 -3
- data/lib/generators/templates/cucumber/partials/watir_env.tt +1 -1
- data/lib/generators/templates/helpers/allure_helper.tt +1 -1
- data/lib/generators/templates/helpers/browser_helper.tt +3 -3
- data/lib/generators/templates/helpers/driver_helper.tt +2 -1
- data/lib/generators/templates/helpers/partials/driver_and_options.tt +25 -0
- data/lib/generators/templates/helpers/partials/screenshot.tt +3 -3
- data/lib/generators/templates/helpers/spec_helper.tt +1 -2
- data/lib/ruby_raider.rb +4 -147
- data/lib/scaffolding/scaffolding.rb +3 -3
- data/lib/utilities/utilities.rb +2 -2
- data/ruby_raider.gemspec +2 -2
- data/spec/{ruby_raider_spec.rb → scaffolding_spec.rb} +73 -78
- metadata +15 -10
- data/lib/generators/templates/helpers/partials/new_driver.tt +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e1928965aa6bf627bbfcf504be2873c8c21b749e15ba58a25031edc3247e8b
|
4
|
+
data.tar.gz: d0616127c4d73bfe475df99036a49ad3a412b795ac84f5514ba018ad9fa902ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32f18b8f33d9beb299bf130e407bad5ca17814e5fa283b87d2eec193c69191b7e9f00a2dfa201a847c3117fd18612ac195c379fbac3655982e4f1b9803694a24
|
7
|
+
data.tar.gz: f3d61d8d65fd5edde333cd9044a3d16e7d37169d1fdbc204996b843fa1f830aa51b303ddad9a37327cf083ea70da5d8d027105805462690b881ad413d9149c06
|
@@ -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/.reek.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,93 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
Exclude:
|
3
5
|
- './spec/*'
|
4
6
|
|
7
|
+
# Layout
|
8
|
+
Layout/CaseIndentation:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Layout/ClosingParenthesisIndentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Layout/LineLength:
|
15
|
+
Max: 999
|
16
|
+
|
17
|
+
Layout/MultilineMethodCallBraceLayout:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Layout/SpaceInsideHashLiteralBraces:
|
21
|
+
StyleGuide: '#spaces-operators'
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
# Lint
|
25
|
+
|
26
|
+
# Metrics
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Max: 100
|
29
|
+
|
30
|
+
Metrics/BlockLength:
|
31
|
+
Max: 150
|
32
|
+
|
33
|
+
Metrics/BlockNesting:
|
34
|
+
Max: 4
|
35
|
+
|
36
|
+
Metrics/ClassLength:
|
37
|
+
CountComments: false
|
38
|
+
Max: 500
|
39
|
+
|
40
|
+
Metrics/CyclomaticComplexity:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Metrics/MethodLength:
|
44
|
+
Max: 150
|
45
|
+
|
46
|
+
Metrics/ModuleLength:
|
47
|
+
Max: 600
|
48
|
+
|
49
|
+
Metrics/ParameterLists:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Metrics/PerceivedComplexity:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Naming/AccessorMethodName:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
# Migration
|
59
|
+
|
60
|
+
# Naming
|
61
|
+
Naming/PredicateName:
|
62
|
+
ForbiddenPrefixes:
|
63
|
+
- 'is_'
|
64
|
+
|
65
|
+
# Security
|
66
|
+
|
67
|
+
# Styles
|
68
|
+
|
69
|
+
Style/AsciiComments:
|
70
|
+
Enabled: false
|
71
|
+
|
5
72
|
Style/Documentation:
|
6
|
-
Enabled: false
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Style/FrozenStringLiteralComment:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Style/HashEachMethods:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Style/HashTransformKeys:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Style/HashTransformValues:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
Style/SafeNavigation:
|
88
|
+
Description: "Use &. instead of checking if an object exists"
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/SingleLineBlockParams:
|
92
|
+
Description: 'Enforces the names of some block params.'
|
93
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Ruby Raider
|
2
2
|
|
3
|
-
|
4
|
-
|
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,26 +15,36 @@ 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
|
15
23
|
|
16
|
-
|
24
|
+
* Generating a framework with Rspec and Selenium
|
17
25
|
|
18
|
-
*
|
19
|
-
* Gerating a Watir with both Cucumber and Rspec framework
|
20
|
-
* Generating an Appium project with Rspec and Cucumber on IOS
|
26
|
+
* Generating a framework with Cucumber and Watir
|
21
27
|
|
22
|
-
|
28
|
+
* Generating a framework with Rspec and Watir
|
23
29
|
|
24
|
-
|
30
|
+
* Generating a framework with Rspec and Appium for IOS
|
31
|
+
|
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
40
|
Commands:
|
29
41
|
raider browser [BROWSER] # Sets the default browser for a project
|
30
42
|
|
43
|
+
raider browser_options [OPTIONS] # Sets the browser options for the project
|
44
|
+
|
31
45
|
raider feature [FEATURE_NAME] # Creates a new feature
|
32
46
|
|
33
|
-
raider help [COMMAND] #
|
47
|
+
raider help [COMMAND] # Describes available commands or one specific command
|
34
48
|
|
35
49
|
raider helper [HELPER_NAME] # Creates a new helper
|
36
50
|
|
@@ -40,9 +54,9 @@ Commands:
|
|
40
54
|
|
41
55
|
raider path [PATH] # Sets the default path for scaffolding
|
42
56
|
|
43
|
-
raider raid #
|
57
|
+
raider raid # Runs all the tests in a project
|
44
58
|
|
45
|
-
raider scaffold [SCAFFOLD_NAME] #
|
59
|
+
raider scaffold [SCAFFOLD_NAME] # Generates everything needed to start automating
|
46
60
|
|
47
61
|
raider spec [SPEC_NAME] # Creates a new spec
|
48
62
|
|
@@ -60,4 +74,4 @@ raider path [PATH_NAME] --spec or -s
|
|
60
74
|
raider path [PATH_NAME] --helper or -h
|
61
75
|
```
|
62
76
|
|
63
|
-
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 '
|
6
|
-
task :new
|
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 '
|
12
|
-
task :page, [:name] do |_t, args|
|
13
|
-
|
14
|
-
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'tty-prompt'
|
4
4
|
require_relative 'automation_generator'
|
5
5
|
require_relative 'common_generator'
|
6
6
|
require_relative 'cucumber_generator'
|
@@ -8,64 +8,70 @@ require_relative 'helper_generator'
|
|
8
8
|
require_relative 'rspec_generator'
|
9
9
|
|
10
10
|
class MenuGenerator
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
menu.choice('Appium') { choose_test_framework('appium', project_name) }
|
19
|
-
menu.choice('Quit') { exit }
|
20
|
-
end
|
21
|
-
end
|
11
|
+
attr_reader :prompt, :name, :generators
|
12
|
+
|
13
|
+
def initialize(project_name)
|
14
|
+
@prompt = TTY::Prompt.new
|
15
|
+
@name = project_name
|
16
|
+
@generators = %w[Automation Common Helpers]
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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}")
|
19
|
+
def generate_choice_menu
|
20
|
+
prompt.select('Please select your automation framework') do |menu|
|
21
|
+
menu.choice :Appium, -> { choose_test_framework('appium') }
|
22
|
+
menu.choice :Selenium, -> { choose_test_framework('selenium') }
|
23
|
+
menu.choice :Watir, -> { choose_test_framework('watir') }
|
24
|
+
menu.choice :Quit, -> { exit }
|
41
25
|
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def choose_test_framework(automation)
|
29
|
+
return choose_mobile_platform if automation == 'appium'
|
42
30
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
31
|
+
select_test_framework(automation)
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_framework(automation, framework)
|
35
|
+
add_generator framework.capitalize
|
36
|
+
generators.each { |generator| invoke_generator(automation, framework, generator) }
|
37
|
+
system "cd #{name} && gem install bundler && bundle install"
|
38
|
+
end
|
39
|
+
|
40
|
+
def choose_mobile_platform
|
41
|
+
prompt.select('Please select your mobile platform') do |menu|
|
42
|
+
menu.choice :iOS, -> { choose_test_framework 'appium_ios' }
|
43
|
+
menu.choice :Android, -> { error_handling('Android') }
|
44
|
+
menu.choice :Cross_Platform, -> { error_handling('Cross Platform') }
|
45
|
+
menu.choice :Quit, -> { exit }
|
53
46
|
end
|
47
|
+
end
|
54
48
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
49
|
+
protected
|
50
|
+
|
51
|
+
def add_generator(*opts)
|
52
|
+
opts.each { |opt| @generators.push opt }
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def framework_choice(framework, automation_type)
|
58
|
+
set_framework(automation_type, framework.downcase)
|
59
|
+
prompt.say("You have chosen to use #{framework} with #{automation_type}")
|
60
|
+
end
|
61
|
+
|
62
|
+
def error_handling(platform)
|
63
|
+
pp "#{platform} appium is coming soon. Thank you for the interest"
|
64
|
+
end
|
65
|
+
|
66
|
+
def select_test_framework(automation)
|
67
|
+
prompt.select('Please select your test framework') do |menu|
|
68
|
+
menu.choice :Cucumber, -> { framework_choice('Rspec', automation) }
|
69
|
+
menu.choice :Rspec, -> { framework_choice('Cucumber', automation) }
|
70
|
+
menu.choice :Quit, -> { exit }
|
69
71
|
end
|
70
72
|
end
|
73
|
+
|
74
|
+
def invoke_generator(automation, framework, generator)
|
75
|
+
Object.const_get("#{generator}Generator").new([automation, framework, name]).invoke_all
|
76
|
+
end
|
71
77
|
end
|
@@ -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)
|
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)
|
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)
|
7
|
+
<%= ERB.new(File.read(File.expand_path('./partials/appium_env.tt', __dir__))).result(binding) %>
|
8
8
|
<% end -%>
|
@@ -7,7 +7,7 @@ Before do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
After do |scenario|
|
10
|
-
browser.
|
10
|
+
browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
|
11
11
|
Raider::AllureHelper.add_screenshot(scenario.name)
|
12
12
|
browser.quit
|
13
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:
|
19
|
+
source: File.open("allure-results/screenshots/#{screenshot_name}.png"),
|
20
20
|
type: Allure::ContentType::PNG,
|
21
21
|
test_case: true
|
22
22
|
)
|
@@ -9,11 +9,11 @@ module Raider
|
|
9
9
|
module BrowserHelper
|
10
10
|
attr_reader :browser
|
11
11
|
|
12
|
-
def new_browser(
|
12
|
+
def new_browser(*args)
|
13
13
|
@config = YAML.load_file('config/config.yml')
|
14
14
|
browser = @config['browser'].to_sym
|
15
|
-
|
16
|
-
@browser = Watir::Browser.new(browser, options:
|
15
|
+
args = args.empty? ? @config['browser_options'] : args
|
16
|
+
@browser = Watir::Browser.new(browser, options: { args: args })
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|