ruby_raider 0.3.1 → 0.3.4
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 +4 -4
- data/README.md +19 -13
- data/Rakefile +1 -1
- data/lib/generators/automation_generator.rb +13 -15
- data/lib/generators/common_generator.rb +0 -1
- data/lib/generators/cucumber_generator.rb +0 -1
- data/lib/generators/generator.rb +2 -2
- data/lib/generators/helper_generator.rb +8 -13
- data/lib/generators/rspec_generator.rb +0 -2
- data/lib/generators/templates/common/read_me.tt +19 -12
- data/lib/generators/templates/cucumber/partials/selenium_appium_env.tt +6 -4
- data/lib/generators/templates/cucumber/partials/watir_env.tt +6 -5
- data/lib/generators/templates/helpers/browser_helper.tt +5 -5
- data/lib/generators/templates/helpers/driver_helper.tt +0 -2
- data/lib/generators/templates/helpers/partials/new_driver.tt +3 -1
- data/lib/generators/templates/helpers/partials/quit_driver.tt +3 -3
- data/lib/generators/templates/helpers/partials/screenshot.tt +3 -3
- data/lib/generators/templates/helpers/partials/select_driver.tt +3 -3
- data/lib/generators/templates/helpers/spec_helper.tt +1 -0
- data/lib/ruby_raider.rb +80 -20
- data/lib/scaffolding/scaffolding.rb +21 -2
- data/lib/scaffolding/templates/helper.tt +3 -0
- data/lib/utilities/utilities.rb +17 -0
- data/ruby_raider.gemspec +2 -3
- data/spec/ruby_raider_spec.rb +83 -3
- metadata +12 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8241d616546918759f985468cc03ff74220a13e2f14215b5a95d8338ae25ce59
|
|
4
|
+
data.tar.gz: bfd3346375daade458db2d5ff5a0071abe6ddeb6ba48e664a3aef2cccc2258b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a16cdbf3e0dd35cdfa3b68c5a9833083510484673f34fad911adc57be61939a8131ed75119d0e4ba95c4240da4cb997f7d09070bd53212248ebd1224919a563
|
|
7
|
+
data.tar.gz: 4a575ffc9c5ef8c21a4bf53730e36aa3c0575dd4094dc17992302c369b9ccab307368650cf71ea33ff00d1ca23e7892ec57810df1bec18fba66e96ab468e696a
|
data/README.md
CHANGED
|
@@ -25,33 +25,39 @@ 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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
Commands:
|
|
29
|
+
raider browser [BROWSER] # Sets the default browser for a project
|
|
30
|
+
|
|
31
|
+
raider feature [FEATURE_NAME] # Creates a new feature
|
|
32
|
+
|
|
33
|
+
raider help [COMMAND] # Describe available commands or one specific command
|
|
34
|
+
|
|
35
|
+
raider helper [HELPER_NAME] # Creates a new helper
|
|
31
36
|
|
|
32
|
-
raider
|
|
37
|
+
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
|
33
38
|
|
|
34
|
-
raider
|
|
39
|
+
raider page [PAGE_NAME] # Creates a new page object
|
|
35
40
|
|
|
36
|
-
raider
|
|
41
|
+
raider path [PATH] # Sets the default path for scaffolding
|
|
37
42
|
|
|
38
|
-
raider
|
|
43
|
+
raider raid # It runs all the tests in a project
|
|
39
44
|
|
|
40
|
-
raider
|
|
45
|
+
raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
|
|
41
46
|
|
|
42
|
-
raider spec [SPEC_NAME]
|
|
47
|
+
raider spec [SPEC_NAME] # Creates a new spec
|
|
43
48
|
|
|
44
|
-
raider url [URL]
|
|
49
|
+
raider url [URL] # Sets the default url for a project
|
|
45
50
|
```
|
|
46
51
|
|
|
47
|
-
It's possible to add the option --path or -p if you want to specify where to create your features, pages and
|
|
48
|
-
|
|
52
|
+
It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
|
|
53
|
+
specs.
|
|
49
54
|
|
|
50
|
-
If you want to set the default path for the creation of your features,
|
|
55
|
+
If you want to set the default path for the creation of your features, helpers and specs:
|
|
51
56
|
|
|
52
57
|
```
|
|
53
58
|
raider path [PATH_NAME] --feature or -f
|
|
54
59
|
raider path [PATH_NAME] --spec or -s
|
|
60
|
+
raider path [PATH_NAME] --helper or -h
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
If you don't specify an option path will assume you want to change the default path for pages
|
data/Rakefile
CHANGED
|
@@ -12,32 +12,30 @@ class AutomationGenerator < Generator
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def generate_home_page
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
return unless @_initializer.first.include?('appium_ios')
|
|
16
|
+
|
|
17
|
+
template('automation/home_page.tt', "#{name}/page_objects/pages/home_page.rb")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def generate_header_component
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return if @_initializer.first.include?('appium_ios')
|
|
22
|
+
|
|
23
|
+
template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def generate_abstract_component
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return if @_initializer.first.include?('appium_ios')
|
|
28
|
+
|
|
29
|
+
template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def generate_confirmation_page
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
return unless @_initializer.first.include?('appium_ios')
|
|
34
|
+
|
|
35
|
+
template('automation/confirmation_page.tt', "#{name}/page_objects/pages/confirmation_page.rb")
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def generate_appium_settings
|
|
39
|
-
if @_initializer.first.include?('appium_ios')
|
|
40
|
-
template('automation/appium_settings.tt', "#{name}/appium.txt")
|
|
41
|
-
end
|
|
39
|
+
template('automation/appium_settings.tt', "#{name}/appium.txt") if @_initializer.first.include?('appium_ios')
|
|
42
40
|
end
|
|
43
41
|
end
|
data/lib/generators/generator.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'thor'
|
|
3
4
|
|
|
4
5
|
class Generator < Thor::Group
|
|
@@ -9,7 +10,6 @@ class Generator < Thor::Group
|
|
|
9
10
|
argument :name
|
|
10
11
|
|
|
11
12
|
def self.source_root
|
|
12
|
-
File.dirname(__FILE__)
|
|
13
|
+
"#{File.dirname(__FILE__)}/templates"
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
|
-
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require_relative 'generator'
|
|
4
4
|
|
|
5
5
|
class HelpersGenerator < Generator
|
|
6
|
-
|
|
7
6
|
def generate_raider_helper
|
|
8
7
|
template('helpers/raider_helper.tt', "#{name}/helpers/raider.rb")
|
|
9
8
|
end
|
|
@@ -13,26 +12,22 @@ class HelpersGenerator < Generator
|
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def generate_browser_helper
|
|
16
|
-
if @_initializer.first.include?('watir')
|
|
17
|
-
template('helpers/browser_helper.tt', "#{name}/helpers/browser_helper.rb")
|
|
18
|
-
end
|
|
15
|
+
template('helpers/browser_helper.tt', "#{name}/helpers/browser_helper.rb") if @_initializer.first.include?('watir')
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
def generate_spec_helper
|
|
22
|
-
if @_initializer.first.include?('rspec')
|
|
23
|
-
template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb")
|
|
24
|
-
end
|
|
19
|
+
template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb") if @_initializer.first.include?('rspec')
|
|
25
20
|
end
|
|
26
21
|
|
|
27
22
|
def generate_selenium_helper
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
return unless @_initializer.first.include?('selenium')
|
|
24
|
+
|
|
25
|
+
template('helpers/selenium_helper.tt', "#{name}/helpers/selenium_helper.rb")
|
|
31
26
|
end
|
|
32
27
|
|
|
33
28
|
def generate_driver_helper
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
return if @_initializer.first.include?('watir')
|
|
30
|
+
|
|
31
|
+
template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
|
|
37
32
|
end
|
|
38
33
|
end
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require_relative 'generator'
|
|
4
4
|
|
|
5
5
|
class RspecGenerator < Generator
|
|
6
|
-
|
|
7
6
|
def generate_spec
|
|
8
7
|
template('rspec/spec.tt', "#{name}/spec/login_page_spec.rb")
|
|
9
8
|
end
|
|
@@ -12,4 +11,3 @@ class RspecGenerator < Generator
|
|
|
12
11
|
template('rspec/base_spec.tt', "#{name}/spec/base_spec.rb")
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
|
-
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Ruby Raider
|
|
2
|
+
|
|
2
3
|
This is a gem to make setup and start of UI automation projects easier
|
|
3
4
|
You can find more information and updates on releases in : https://ruby-raider.com/
|
|
4
5
|
|
|
@@ -24,33 +25,39 @@ This works in all the platforms (Tested on Mac OS, Linux and Windows)
|
|
|
24
25
|
|
|
25
26
|
**Ruby raider provides the following list of commands**
|
|
26
27
|
```
|
|
27
|
-
|
|
28
|
+
Commands:
|
|
29
|
+
raider browser [BROWSER] # Sets the default browser for a project
|
|
30
|
+
|
|
31
|
+
raider feature [FEATURE_NAME] # Creates a new feature
|
|
32
|
+
|
|
33
|
+
raider help [COMMAND] # Describe available commands or one specific command
|
|
28
34
|
|
|
29
|
-
raider
|
|
35
|
+
raider helper [HELPER_NAME] # Creates a new helper
|
|
30
36
|
|
|
31
|
-
raider
|
|
37
|
+
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
|
32
38
|
|
|
33
|
-
raider
|
|
39
|
+
raider page [PAGE_NAME] # Creates a new page object
|
|
34
40
|
|
|
35
|
-
raider
|
|
41
|
+
raider path [PATH] # Sets the default path for scaffolding
|
|
36
42
|
|
|
37
|
-
raider
|
|
43
|
+
raider raid # It runs all the tests in a project
|
|
38
44
|
|
|
39
|
-
raider
|
|
45
|
+
raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
|
|
40
46
|
|
|
41
|
-
raider spec [SPEC_NAME]
|
|
47
|
+
raider spec [SPEC_NAME] # Creates a new spec
|
|
42
48
|
|
|
43
|
-
raider url [URL]
|
|
49
|
+
raider url [URL] # Sets the default url for a project
|
|
44
50
|
```
|
|
45
51
|
|
|
46
|
-
It's possible to add the option --path or -p if you want to specify where to create your features, pages and
|
|
47
|
-
|
|
52
|
+
It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
|
|
53
|
+
specs.
|
|
48
54
|
|
|
49
|
-
If you want to set the default path for the creation of your features,
|
|
55
|
+
If you want to set the default path for the creation of your features, helpers and specs:
|
|
50
56
|
|
|
51
57
|
```
|
|
52
58
|
raider path [PATH_NAME] --feature or -f
|
|
53
59
|
raider path [PATH_NAME] --spec or -s
|
|
60
|
+
raider path [PATH_NAME] --helper or -h
|
|
54
61
|
```
|
|
55
62
|
|
|
56
63
|
If you don't specify an option path will assume you want to change the default path for pages
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
require_relative '../../helpers/driver_helper'
|
|
2
2
|
|
|
3
|
+
include Raider::DriverHelper
|
|
4
|
+
|
|
3
5
|
Before do
|
|
4
|
-
|
|
6
|
+
new_driver
|
|
5
7
|
end
|
|
6
8
|
|
|
7
9
|
After do |scenario|
|
|
8
|
-
|
|
10
|
+
driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
|
|
9
11
|
Raider::AllureHelper.add_screenshot(scenario.name)
|
|
10
|
-
|
|
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
|
-
|
|
5
|
-
@browser = Raider::BrowserHelper.new_browser
|
|
6
|
+
new_browser
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
After do |scenario|
|
|
9
|
-
|
|
10
|
+
browser.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
|
|
10
11
|
Raider::AllureHelper.add_screenshot(scenario.name)
|
|
11
|
-
|
|
12
|
-
end
|
|
12
|
+
browser.quit
|
|
13
|
+
end
|
|
@@ -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(
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
def new_browser(opts = {})
|
|
13
|
+
@config = YAML.load_file('config/config.yml')
|
|
14
|
+
browser = @config['browser'].to_sym
|
|
15
|
+
opts = opts.nil? ? @config['browser_options'] : opts
|
|
16
|
+
@browser = Watir::Browser.new(browser, options: opts)
|
|
16
17
|
end
|
|
17
|
-
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<% if automation == 'selenium' %>
|
|
2
2
|
def new_driver(caps = {})
|
|
3
|
-
|
|
3
|
+
@config = YAML.load_file('config/config.yml')
|
|
4
|
+
browser = @config['browser'].to_sym
|
|
5
|
+
caps = caps.nil? ? @config['browser_options'] : caps
|
|
4
6
|
@driver = Selenium::WebDriver.for(browser, desired_capabilities: caps)
|
|
5
7
|
end
|
|
6
8
|
<% else %>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<% case automation
|
|
2
2
|
when 'selenium' %>
|
|
3
|
-
|
|
3
|
+
driver.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
|
|
4
4
|
<% when 'watir' %>
|
|
5
|
-
|
|
5
|
+
browser.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
|
|
6
6
|
<% else %>
|
|
7
|
-
|
|
7
|
+
driver.screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
|
|
8
8
|
<% end %>
|
|
@@ -14,6 +14,7 @@ module Raider
|
|
|
14
14
|
AllureHelper.configure
|
|
15
15
|
RSpec.configure do |config|
|
|
16
16
|
config.formatter = AllureHelper.formatter
|
|
17
|
+
<% if automation == 'watir' %>config.include(BrowserHelper)<% else %>config.include(DriverHelper)<% end %>
|
|
17
18
|
config.before(:each) do
|
|
18
19
|
<%= ERB.new(File.read(File.expand_path('./partials/select_driver.tt', __dir__))).result(binding).strip! %>
|
|
19
20
|
end
|
data/lib/ruby_raider.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'thor'
|
|
2
4
|
require 'yaml'
|
|
3
5
|
require_relative 'generators/menu_generator'
|
|
@@ -5,17 +7,18 @@ require_relative '../lib/scaffolding/scaffolding'
|
|
|
5
7
|
require_relative '../lib/utilities/utilities'
|
|
6
8
|
|
|
7
9
|
class RubyRaider < Thor
|
|
8
|
-
desc
|
|
10
|
+
desc 'new [PROJECT_NAME]', 'Creates a new framework based on settings picked'
|
|
9
11
|
|
|
10
12
|
def new(project_name)
|
|
11
13
|
MenuGenerator.generate_choice_menu(project_name)
|
|
12
14
|
end
|
|
15
|
+
map '-n' => "new"
|
|
13
16
|
|
|
14
|
-
desc
|
|
17
|
+
desc 'page [PAGE_NAME]', 'Creates a new page object'
|
|
15
18
|
option :path,
|
|
16
|
-
:
|
|
19
|
+
type: :string, required: false, desc: 'The path where your page will be created', aliases: '-p'
|
|
17
20
|
option :delete,
|
|
18
|
-
:
|
|
21
|
+
type: :boolean, required: false, desc: 'This will delete the selected page', aliases: '-d'
|
|
19
22
|
|
|
20
23
|
def page(name)
|
|
21
24
|
path = options[:path].nil? ? load_config_path('page') : options[:path]
|
|
@@ -25,12 +28,13 @@ class RubyRaider < Thor
|
|
|
25
28
|
Scaffolding.new([name, path]).generate_class
|
|
26
29
|
end
|
|
27
30
|
end
|
|
31
|
+
map '-pg' => "page"
|
|
28
32
|
|
|
29
|
-
desc
|
|
33
|
+
desc 'feature [FEATURE_NAME]', 'Creates a new feature'
|
|
30
34
|
option :path,
|
|
31
|
-
:
|
|
35
|
+
type: :string, required: false, desc: 'The path where your feature will be created', aliases: '-p'
|
|
32
36
|
option :delete,
|
|
33
|
-
:
|
|
37
|
+
type: :boolean, required: false, desc: 'This will delete the selected feature', aliases: '-d'
|
|
34
38
|
|
|
35
39
|
def feature(name)
|
|
36
40
|
path = options[:path].nil? ? load_config_path('feature') : options[:path]
|
|
@@ -40,12 +44,13 @@ class RubyRaider < Thor
|
|
|
40
44
|
Scaffolding.new([name, path]).generate_feature
|
|
41
45
|
end
|
|
42
46
|
end
|
|
47
|
+
map '-f' => "feature"
|
|
43
48
|
|
|
44
|
-
desc
|
|
49
|
+
desc 'spec [SPEC_NAME]', 'Creates a new spec'
|
|
45
50
|
option :path,
|
|
46
|
-
:
|
|
51
|
+
type: :string, required: false, desc: 'The path where your spec will be created', aliases: '-p'
|
|
47
52
|
option :delete,
|
|
48
|
-
:
|
|
53
|
+
type: :boolean, required: false, desc: 'This will delete the selected spec', aliases: '-d'
|
|
49
54
|
|
|
50
55
|
def spec(name)
|
|
51
56
|
path = options[:path].nil? ? load_config_path('spec') : options[:path]
|
|
@@ -55,34 +60,89 @@ class RubyRaider < Thor
|
|
|
55
60
|
Scaffolding.new([name, path]).generate_spec
|
|
56
61
|
end
|
|
57
62
|
end
|
|
63
|
+
map '-s' => "spec"
|
|
64
|
+
|
|
65
|
+
desc 'helper [HELPER_NAME]', 'Creates a new helper'
|
|
66
|
+
option :path,
|
|
67
|
+
type: :string, required: false, desc: 'The path where your helper will be created', aliases: '-p'
|
|
68
|
+
option :delete,
|
|
69
|
+
type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d'
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
def helper(name)
|
|
72
|
+
path = options[:path].nil? ? load_config_path('helper') : options[:path]
|
|
73
|
+
if options[:delete]
|
|
74
|
+
Scaffolding.new([name, path]).delete_helper
|
|
75
|
+
else
|
|
76
|
+
Scaffolding.new([name, path]).generate_helper
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
map '-h' => "helper"
|
|
80
|
+
|
|
81
|
+
desc 'path [PATH]', 'Sets the default path for scaffolding'
|
|
60
82
|
option :feature,
|
|
61
|
-
:
|
|
83
|
+
type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
|
|
84
|
+
option :helper,
|
|
85
|
+
type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
|
|
62
86
|
option :spec,
|
|
63
|
-
:
|
|
87
|
+
type: :boolean, required: false, desc: 'The default path for your specs', aliases: '-s'
|
|
64
88
|
def path(default_path)
|
|
65
89
|
type = options.empty? ? 'page' : options.keys.first
|
|
66
90
|
Utilities.new.send("#{type}_path=", default_path)
|
|
67
91
|
end
|
|
92
|
+
map '-p' => "path"
|
|
68
93
|
|
|
69
|
-
desc
|
|
94
|
+
desc 'url [URL]', 'Sets the default url for a project'
|
|
70
95
|
|
|
71
96
|
def url(default_url)
|
|
72
97
|
Utilities.new.url = default_url
|
|
73
98
|
end
|
|
99
|
+
map '-u' => "url"
|
|
74
100
|
|
|
75
|
-
desc
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
101
|
+
desc 'browser [BROWSER]', 'Sets the default browser for a project'
|
|
102
|
+
option :opts,
|
|
103
|
+
type: :hash, required: false, desc: 'The options you want your browser to run with', aliases: '-o'
|
|
104
|
+
option :delete,
|
|
105
|
+
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
|
|
106
|
+
def browser(default_browser = nil)
|
|
107
|
+
Utilities.new.browser = default_browser unless default_browser.nil?
|
|
108
|
+
Utilities.new.browser_options = options[:opts] unless options[:opts].nil?
|
|
109
|
+
Utilities.new.delete_browser_options if options[:delete]
|
|
79
110
|
end
|
|
111
|
+
map '-b' => "browser"
|
|
80
112
|
|
|
81
|
-
desc
|
|
82
|
-
|
|
113
|
+
desc 'raid', 'It runs all the tests in a project'
|
|
83
114
|
def raid
|
|
84
115
|
Utilities.new.run
|
|
85
116
|
end
|
|
117
|
+
map '-r' => "raid"
|
|
118
|
+
|
|
119
|
+
desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
|
|
120
|
+
def scaffold(name)
|
|
121
|
+
if Pathname.new('spec').exist? && !Pathname.new('features').exist?
|
|
122
|
+
Scaffolding.new([name, load_config_path('spec')]).generate_spec
|
|
123
|
+
Scaffolding.new([name, load_config_path('page')]).generate_class
|
|
124
|
+
elsif Pathname.new('features').exist?
|
|
125
|
+
Scaffolding.new([name, load_config_path('feature')]).generate_feature
|
|
126
|
+
Scaffolding.new([name, load_config_path('page')]).generate_class
|
|
127
|
+
else
|
|
128
|
+
raise 'No features or spec folders where found. We are not sure which type of project you are running'
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
map '-sf' => "scaffold"
|
|
132
|
+
|
|
133
|
+
desc 'config', 'Creates a new config file'
|
|
134
|
+
option :path,
|
|
135
|
+
type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
|
|
136
|
+
option :delete,
|
|
137
|
+
type: :boolean, required: false, desc: 'This will delete the selected config file', aliases: '-d'
|
|
138
|
+
def config
|
|
139
|
+
if options[:delete]
|
|
140
|
+
Scaffolding.new.delete_config
|
|
141
|
+
else
|
|
142
|
+
Scaffolding.new.generate_config
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
map '-c' => "config"
|
|
86
146
|
|
|
87
147
|
no_commands do
|
|
88
148
|
def load_config_path(type)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'thor'
|
|
2
4
|
|
|
3
5
|
class Scaffolding < Thor::Group
|
|
4
6
|
include Thor::Actions
|
|
5
7
|
|
|
6
|
-
argument :name
|
|
8
|
+
argument :name, optional: true
|
|
7
9
|
argument :path, optional: true
|
|
8
10
|
|
|
9
11
|
def self.source_root
|
|
10
|
-
File.dirname(__FILE__)
|
|
12
|
+
"#{File.dirname(__FILE__)}/templates"
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def generate_class
|
|
@@ -22,6 +24,15 @@ class Scaffolding < Thor::Group
|
|
|
22
24
|
template('spec.tt', default_path("spec/#{name}_spec.rb", '_spec.rb'))
|
|
23
25
|
end
|
|
24
26
|
|
|
27
|
+
def generate_helper
|
|
28
|
+
template('helper.tt', default_path("helpers/#{name}_helper.rb", '_helper.rb'))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def generate_config
|
|
32
|
+
template('../../generators/templates/common/config.tt',
|
|
33
|
+
default_path("config/config.yml", '.yml'))
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
def delete_class
|
|
26
37
|
remove_file(default_path("page_objects/pages/#{name}_page.rb", '_page.rb'))
|
|
27
38
|
end
|
|
@@ -34,6 +45,14 @@ class Scaffolding < Thor::Group
|
|
|
34
45
|
remove_file(default_path("spec/#{name}_spec.rb", '_spec.rb'))
|
|
35
46
|
end
|
|
36
47
|
|
|
48
|
+
def delete_helper
|
|
49
|
+
remove_file(default_path("helpers/#{name}_helper.rb", '_helper.rb'))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def delete_config
|
|
53
|
+
remove_file(default_path("config/config.yml", '.yml'))
|
|
54
|
+
end
|
|
55
|
+
|
|
37
56
|
def default_path(standard_path, file_type)
|
|
38
57
|
path.nil? ? standard_path : "#{path}/#{name}#{file_type}"
|
|
39
58
|
end
|
data/lib/utilities/utilities.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'yaml'
|
|
2
4
|
|
|
3
5
|
class Utilities
|
|
@@ -26,11 +28,26 @@ class Utilities
|
|
|
26
28
|
overwrite_yaml
|
|
27
29
|
end
|
|
28
30
|
|
|
31
|
+
def helper_path=(path)
|
|
32
|
+
@config['helper_path'] = path
|
|
33
|
+
overwrite_yaml
|
|
34
|
+
end
|
|
35
|
+
|
|
29
36
|
def url=(url)
|
|
30
37
|
@config['url'] = url
|
|
31
38
|
overwrite_yaml
|
|
32
39
|
end
|
|
33
40
|
|
|
41
|
+
def browser_options=(opts)
|
|
42
|
+
@config['browser_options'] = opts
|
|
43
|
+
overwrite_yaml
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def delete_browser_options
|
|
47
|
+
@config.delete('browser_options')
|
|
48
|
+
overwrite_yaml
|
|
49
|
+
end
|
|
50
|
+
|
|
34
51
|
def run
|
|
35
52
|
if File.directory? 'spec'
|
|
36
53
|
system 'rspec spec/'
|
data/ruby_raider.gemspec
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = 'ruby_raider'
|
|
5
|
-
s.version = '0.3.
|
|
5
|
+
s.version = '0.3.4'
|
|
6
6
|
s.summary = 'A gem to make setup and start of UI automation projects easier'
|
|
7
7
|
s.description = 'This gem has everything you need to start working with test automation'
|
|
8
8
|
s.authors = ['Agustin Pequeno']
|
|
9
9
|
s.email = 'agustin.pe94@gmail.com'
|
|
10
10
|
s.homepage = 'https://github.com/RubyRaider/ruby_raider'
|
|
11
|
-
s.files = %w[bin/* lib/* lib/**/*]
|
|
12
11
|
s.license = 'MIT'
|
|
13
12
|
s.required_ruby_version = '>= 3.0.0'
|
|
14
13
|
s.files = `git ls-files -z`.split("\x0")
|
|
@@ -16,9 +15,9 @@ Gem::Specification.new do |s|
|
|
|
16
15
|
s.executables << 'raider'
|
|
17
16
|
s.add_development_dependency 'rake', '~> 13.0.6'
|
|
18
17
|
s.add_development_dependency 'reek', '~> 6.1.0'
|
|
18
|
+
s.add_development_dependency 'rspec', '~> 3.11.0'
|
|
19
19
|
s.add_development_dependency 'rubocop', '~> 1.27'
|
|
20
20
|
s.add_development_dependency 'rubocop-rspec', '~> 2.9.0'
|
|
21
|
-
s.add_development_dependency 'rspec', '~> 3.11.0'
|
|
22
21
|
|
|
23
22
|
s.add_runtime_dependency 'highline', '~> 2.0.3'
|
|
24
23
|
s.add_runtime_dependency 'thor', '~> 1.2.1'
|
data/spec/ruby_raider_spec.rb
CHANGED
|
@@ -29,6 +29,11 @@ describe RubyRaider do
|
|
|
29
29
|
expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
it 'creates a helper' do
|
|
33
|
+
raider.new.invoke(:helper, nil, %W[#{name}])
|
|
34
|
+
expect(Pathname.new("helpers/#{name}_helper.rb")).to be_file
|
|
35
|
+
end
|
|
36
|
+
|
|
32
37
|
it 'deletes a page' do
|
|
33
38
|
raider.new.invoke(:page, nil, %W[#{name}])
|
|
34
39
|
raider.new.invoke(:page, nil, %W[#{name} --delete])
|
|
@@ -47,8 +52,14 @@ describe RubyRaider do
|
|
|
47
52
|
expect(Pathname.new("spec/#{name}_spec.rb")).to_not be_file
|
|
48
53
|
end
|
|
49
54
|
|
|
55
|
+
it 'deletes a helper' do
|
|
56
|
+
raider.new.invoke(:helper, nil, %W[#{name}])
|
|
57
|
+
raider.new.invoke(:helper, nil, %W[#{name} --delete])
|
|
58
|
+
expect(Pathname.new("helpers/#{name}_helper.rb")).to_not be_file
|
|
59
|
+
end
|
|
60
|
+
|
|
50
61
|
after(:all) do
|
|
51
|
-
folders = %w[test config page_objects features]
|
|
62
|
+
folders = %w[test config page_objects features helpers]
|
|
52
63
|
folders.each do |folder|
|
|
53
64
|
FileUtils.rm_rf(folder)
|
|
54
65
|
end
|
|
@@ -74,6 +85,11 @@ describe RubyRaider do
|
|
|
74
85
|
expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
|
|
75
86
|
end
|
|
76
87
|
|
|
88
|
+
it 'creates a helper' do
|
|
89
|
+
raider.new.invoke(:helper, nil, %W[#{name} --path #{path}])
|
|
90
|
+
expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
|
|
91
|
+
end
|
|
92
|
+
|
|
77
93
|
after(:each) do
|
|
78
94
|
FileUtils.rm_rf(path)
|
|
79
95
|
end
|
|
@@ -117,12 +133,18 @@ describe RubyRaider do
|
|
|
117
133
|
expect(Pathname.new("#{path}/#{name}.feature")).to be_file
|
|
118
134
|
end
|
|
119
135
|
|
|
120
|
-
it 'creates
|
|
136
|
+
it 'creates spec' do
|
|
121
137
|
raider.new.invoke(:path, nil, %W[#{path} -s])
|
|
122
138
|
raider.new.invoke(:spec, nil, %W[#{name}])
|
|
123
139
|
expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
|
|
124
140
|
end
|
|
125
141
|
|
|
142
|
+
it 'creates spec' do
|
|
143
|
+
raider.new.invoke(:path, nil, %W[#{path} -h])
|
|
144
|
+
raider.new.invoke(:helper, nil, %W[#{name}])
|
|
145
|
+
expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
|
|
146
|
+
end
|
|
147
|
+
|
|
126
148
|
after(:all) do
|
|
127
149
|
folders = %w[test_folder test config]
|
|
128
150
|
folders.each do |folder|
|
|
@@ -133,7 +155,7 @@ describe RubyRaider do
|
|
|
133
155
|
|
|
134
156
|
context 'updates the config file' do
|
|
135
157
|
before(:all) do
|
|
136
|
-
CommonGenerator.new(%w[rspec
|
|
158
|
+
CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
|
|
137
159
|
FileUtils.cp_lr('test/config', './')
|
|
138
160
|
end
|
|
139
161
|
|
|
@@ -149,6 +171,32 @@ describe RubyRaider do
|
|
|
149
171
|
expect(config['browser']).to eql ':firefox'
|
|
150
172
|
end
|
|
151
173
|
|
|
174
|
+
it 'updates the browser and the browser options' do
|
|
175
|
+
raider.new.invoke(:browser, nil, %W[:firefox --opts headless:test])
|
|
176
|
+
config = YAML.load_file('config/config.yml')
|
|
177
|
+
expect(config['browser']).to eql ':firefox'
|
|
178
|
+
expect(config['browser_options']).to eql "headless" => "test"
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'updates only the browser options' do
|
|
182
|
+
raider.new.invoke(:browser, nil, %W[:firefox --opts headless:test])
|
|
183
|
+
config = YAML.load_file('config/config.yml')
|
|
184
|
+
expect(config['browser_options']).to eql "headless" => "test"
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it 'deletes the browser options when passed with the delete parameter' do
|
|
188
|
+
raider.new.invoke(:browser, nil, %W[:firefox --opts headless:test --delete])
|
|
189
|
+
config = YAML.load_file('config/config.yml')
|
|
190
|
+
expect(config['browser_options']).to be_nil
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'deletes the browser options' do
|
|
194
|
+
raider.new.invoke(:browser, nil, %W[:firefox --opts headless:test])
|
|
195
|
+
raider.new.invoke(:browser, nil, %W[--delete])
|
|
196
|
+
config = YAML.load_file('config/config.yml')
|
|
197
|
+
expect(config['browser_options']).to be_nil
|
|
198
|
+
end
|
|
199
|
+
|
|
152
200
|
after(:all) do
|
|
153
201
|
folders = %w[test config]
|
|
154
202
|
folders.each do |folder|
|
|
@@ -156,4 +204,36 @@ describe RubyRaider do
|
|
|
156
204
|
end
|
|
157
205
|
end
|
|
158
206
|
end
|
|
207
|
+
|
|
208
|
+
context 'scaffolding' do
|
|
209
|
+
before(:all) do
|
|
210
|
+
CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
|
|
211
|
+
FileUtils.cp_lr('test/config', './')
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
context 'with a spec folder' do
|
|
215
|
+
it 'scaffolds for rspec' do
|
|
216
|
+
raider.new.invoke(:scaffold, nil, %W[#{name}])
|
|
217
|
+
expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
|
|
218
|
+
expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
context 'with a features folder' do
|
|
223
|
+
it 'scaffolds for cucumber' do
|
|
224
|
+
FileUtils.mkdir 'features'
|
|
225
|
+
raider.new.invoke(:scaffold, nil, %W[#{name}])
|
|
226
|
+
expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
|
|
227
|
+
expect(Pathname.new("features/#{name}.feature")).to be_file
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
after(:all) do
|
|
232
|
+
folders = %w[test config page_objects features]
|
|
233
|
+
folders.each do |folder|
|
|
234
|
+
FileUtils.rm_rf(folder)
|
|
235
|
+
end
|
|
236
|
+
FileUtils.rm('spec/test_spec.rb') if Pathname.new('spec/test_spec.rb').exist?
|
|
237
|
+
end
|
|
238
|
+
end
|
|
159
239
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_raider
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Agustin Pequeno
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-06-
|
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -39,47 +39,47 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 6.1.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 3.11.0
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 3.11.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rubocop
|
|
56
|
+
name: rubocop
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: '1.27'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: '1.27'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rspec
|
|
70
|
+
name: rubocop-rspec
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: 2.9.0
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 2.9.0
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: highline
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -180,6 +180,7 @@ files:
|
|
|
180
180
|
- lib/ruby_raider.rb
|
|
181
181
|
- lib/scaffolding/scaffolding.rb
|
|
182
182
|
- lib/scaffolding/templates/feature.tt
|
|
183
|
+
- lib/scaffolding/templates/helper.tt
|
|
183
184
|
- lib/scaffolding/templates/page_object.tt
|
|
184
185
|
- lib/scaffolding/templates/spec.tt
|
|
185
186
|
- lib/utilities/utilities.rb
|