ruby_raider 0.3.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07240bddaf0b3edae4d1d8202df31ac428c143941680f02fb51ea54a8b478d37
4
- data.tar.gz: 887a4fc52c2c5899cc5999292a1edd3a357d1ecedbac9dea691edb06f980c6f5
3
+ metadata.gz: 8241d616546918759f985468cc03ff74220a13e2f14215b5a95d8338ae25ce59
4
+ data.tar.gz: bfd3346375daade458db2d5ff5a0071abe6ddeb6ba48e664a3aef2cccc2258b6
5
5
  SHA512:
6
- metadata.gz: d4cf0f65241e104cb96ee22ee79e61a24e049cf834aed0ea0098ea801f64cabe0a037d3846f50c5d60148b50e4a2621fa06329f1a697ea2ee8750b6656c78a49
7
- data.tar.gz: ed34541a0df8cf638630d6db03617e1aff99a0fb7432378971ccd371242be91624c3940e94769acc9d5058194b27a946d40c15a955291ff2d5dee5de5d413e55
6
+ metadata.gz: 3a16cdbf3e0dd35cdfa3b68c5a9833083510484673f34fad911adc57be61939a8131ed75119d0e4ba95c4240da4cb997f7d09070bd53212248ebd1224919a563
7
+ data.tar.gz: 4a575ffc9c5ef8c21a4bf53730e36aa3c0575dd4094dc17992302c369b9ccab307368650cf71ea33ff00d1ca23e7892ec57810df1bec18fba66e96ab468e696a
data/README.md CHANGED
@@ -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
29
-
30
- raider feature [FEATURE_NAME] # Creates a new feature
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
31
34
 
32
- raider help [COMMAND] # Describe available commands or one specific command
35
+ raider helper [HELPER_NAME] # Creates a new helper
33
36
 
34
- raider helper [HELPER_NAME] # Creates a new helper
37
+ raider new [PROJECT_NAME] # Creates a new framework based on settings picked
35
38
 
36
- raider new [PROJECT_NAME] # Creates a new framework based on settings picked
39
+ raider page [PAGE_NAME] # Creates a new page object
37
40
 
38
- raider page [PAGE_NAME] # Creates a new page object
41
+ raider path [PATH] # Sets the default path for scaffolding
39
42
 
40
- raider path [PATH] # Sets the default path for scaffolding
43
+ raider raid # It runs all the tests in a project
41
44
 
42
- raider raid # It runs all the tests in a project
45
+ raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
43
46
 
44
- raider spec [SPEC_NAME] # Creates a new spec
47
+ raider spec [SPEC_NAME] # Creates a new spec
45
48
 
46
- raider url [URL] # Sets the default url for a project
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
@@ -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,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.save_screenshot("allure-results/screenshots/#{scenario.name}.png")
10
11
  Raider::AllureHelper.add_screenshot(scenario.name)
11
- @browser.quit
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(options = {})
14
- browser = YAML.load_file('config/config.yml')['browser'].to_sym
15
- @browser = Watir::Browser.new(browser, options: options)
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
@@ -9,10 +9,8 @@ require_relative 'driver_helper'
9
9
 
10
10
  module Raider
11
11
  module DriverHelper
12
- class << self
13
12
  attr_reader :driver
14
13
 
15
14
  <%= ERB.new(File.read(File.expand_path('./partials/new_driver.tt', __dir__))).result(binding).strip! %>
16
- end
17
15
  end
18
16
  end
@@ -1,6 +1,8 @@
1
1
  <% if automation == 'selenium' %>
2
2
  def new_driver(caps = {})
3
- browser = YAML.load_file('config/config.yml')['browser'].to_sym
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
- DriverHelper.driver.quit
3
+ driver.quit
4
4
  <% when 'watir' %>
5
- BrowserHelper.browser.quit
5
+ browser.quit
6
6
  <% else %>
7
- DriverHelper.driver.quit_driver
7
+ driver.quit_driver
8
8
  <% end %>
@@ -1,8 +1,8 @@
1
1
  <% case automation
2
2
  when 'selenium' %>
3
- @driver.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
3
+ driver.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
4
4
  <% when 'watir' %>
5
- @browser.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
5
+ browser.save_screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
6
6
  <% else %>
7
- @driver.screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
7
+ driver.screenshot("allure-results/screenshots/#{example_name}.png") if status == :failed
8
8
  <% end %>
@@ -1,8 +1,8 @@
1
1
  <% if automation == 'watir' %>
2
- @browser = BrowserHelper.new_browser
2
+ new_browser
3
3
  <% else %>
4
- @driver = DriverHelper.new_driver
4
+ new_driver
5
5
  <% end %>
6
6
  <% if %w[appium_ios].include? automation %>
7
- @driver.start_driver
7
+ start_driver
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
@@ -12,6 +12,7 @@ class RubyRaider < Thor
12
12
  def new(project_name)
13
13
  MenuGenerator.generate_choice_menu(project_name)
14
14
  end
15
+ map '-n' => "new"
15
16
 
16
17
  desc 'page [PAGE_NAME]', 'Creates a new page object'
17
18
  option :path,
@@ -27,6 +28,7 @@ class RubyRaider < Thor
27
28
  Scaffolding.new([name, path]).generate_class
28
29
  end
29
30
  end
31
+ map '-pg' => "page"
30
32
 
31
33
  desc 'feature [FEATURE_NAME]', 'Creates a new feature'
32
34
  option :path,
@@ -42,6 +44,7 @@ class RubyRaider < Thor
42
44
  Scaffolding.new([name, path]).generate_feature
43
45
  end
44
46
  end
47
+ map '-f' => "feature"
45
48
 
46
49
  desc 'spec [SPEC_NAME]', 'Creates a new spec'
47
50
  option :path,
@@ -57,6 +60,7 @@ class RubyRaider < Thor
57
60
  Scaffolding.new([name, path]).generate_spec
58
61
  end
59
62
  end
63
+ map '-s' => "spec"
60
64
 
61
65
  desc 'helper [HELPER_NAME]', 'Creates a new helper'
62
66
  option :path,
@@ -72,6 +76,7 @@ class RubyRaider < Thor
72
76
  Scaffolding.new([name, path]).generate_helper
73
77
  end
74
78
  end
79
+ map '-h' => "helper"
75
80
 
76
81
  desc 'path [PATH]', 'Sets the default path for scaffolding'
77
82
  option :feature,
@@ -84,24 +89,32 @@ class RubyRaider < Thor
84
89
  type = options.empty? ? 'page' : options.keys.first
85
90
  Utilities.new.send("#{type}_path=", default_path)
86
91
  end
92
+ map '-p' => "path"
87
93
 
88
94
  desc 'url [URL]', 'Sets the default url for a project'
89
95
 
90
96
  def url(default_url)
91
97
  Utilities.new.url = default_url
92
98
  end
99
+ map '-u' => "url"
93
100
 
94
101
  desc 'browser [BROWSER]', 'Sets the default browser for a project'
95
-
96
- def browser(default_browser)
97
- Utilities.new.browser = default_browser
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]
98
110
  end
111
+ map '-b' => "browser"
99
112
 
100
113
  desc 'raid', 'It runs all the tests in a project'
101
-
102
114
  def raid
103
115
  Utilities.new.run
104
116
  end
117
+ map '-r' => "raid"
105
118
 
106
119
  desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
107
120
  def scaffold(name)
@@ -115,6 +128,21 @@ class RubyRaider < Thor
115
128
  raise 'No features or spec folders where found. We are not sure which type of project you are running'
116
129
  end
117
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"
118
146
 
119
147
  no_commands do
120
148
  def load_config_path(type)
@@ -5,7 +5,7 @@ require 'thor'
5
5
  class Scaffolding < Thor::Group
6
6
  include Thor::Actions
7
7
 
8
- argument :name
8
+ argument :name, optional: true
9
9
  argument :path, optional: true
10
10
 
11
11
  def self.source_root
@@ -28,6 +28,11 @@ class Scaffolding < Thor::Group
28
28
  template('helper.tt', default_path("helpers/#{name}_helper.rb", '_helper.rb'))
29
29
  end
30
30
 
31
+ def generate_config
32
+ template('../../generators/templates/common/config.tt',
33
+ default_path("config/config.yml", '.yml'))
34
+ end
35
+
31
36
  def delete_class
32
37
  remove_file(default_path("page_objects/pages/#{name}_page.rb", '_page.rb'))
33
38
  end
@@ -44,6 +49,10 @@ class Scaffolding < Thor::Group
44
49
  remove_file(default_path("helpers/#{name}_helper.rb", '_helper.rb'))
45
50
  end
46
51
 
52
+ def delete_config
53
+ remove_file(default_path("config/config.yml", '.yml'))
54
+ end
55
+
47
56
  def default_path(standard_path, file_type)
48
57
  path.nil? ? standard_path : "#{path}/#{name}#{file_type}"
49
58
  end
@@ -38,6 +38,16 @@ class Utilities
38
38
  overwrite_yaml
39
39
  end
40
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
+
41
51
  def run
42
52
  if File.directory? 'spec'
43
53
  system 'rspec spec/'
data/ruby_raider.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ruby_raider'
5
- s.version = '0.3.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']
@@ -171,6 +171,32 @@ describe RubyRaider do
171
171
  expect(config['browser']).to eql ':firefox'
172
172
  end
173
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
+
174
200
  after(:all) do
175
201
  folders = %w[test config]
176
202
  folders.each do |folder|
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.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-05 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake