ruby_raider 0.3.2 → 0.3.5

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: 3b40b177b2b89c4585ae988d6c1747e7eb58761d4817cac54a194ae532f80d77
4
- data.tar.gz: e758ab9ef9922f963b5f3da0763713c7c1cba1890d1d6974b687a6fa62a7eaed
3
+ metadata.gz: 045a0c59f5595a6598342955964d1f666dd5a7366794c88e2250f0817fd47558
4
+ data.tar.gz: 264214ab1455c81dab39b71a96a810d65169eaa8a385c254048a0f4926a7ac35
5
5
  SHA512:
6
- metadata.gz: 574e301014b379f362a08aba90a5dda00391210c602d751a0f6e953c37f19c9c07364c9556944eae47b5ef15a58f2170b1530436fef6c520454895de72f8c253
7
- data.tar.gz: a2f4a9319b508daf6ffb39498eeeacb97b1544ddd44eb19e9832c2db69c121c8df7c784002de9e5847e9d6732db997b63996d98ea285eda8f4c10544f170f8dd
6
+ metadata.gz: e3bac2468b6064901f66259f96d9b3296a7bc3ccd60636f134b25512522f030327b1999d3bcc0ad5a6802ec69abde7caab7f4fca94e720875eb9625bed9b43a1
7
+ data.tar.gz: 73d5ef7d7aa9b04e0960457ab750f549302ea087e043e08c4f745364a12cbcb0cd21abfd2b8baf5bf8c040ef50c3e7b623ed8cfa20203e86d27ff9d5ea941e5b
data/README.md CHANGED
@@ -13,11 +13,19 @@ then do:
13
13
 
14
14
  and you will have a new project in the folder you are in
15
15
 
16
- Currently we only support:
16
+ Currently we support:
17
17
 
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
18
+ * Gerating a framework with Cucumber and Selenium
19
+
20
+ * Generating a framework with Rspec and Selenium
21
+
22
+ * Generating a framework with Cucumber and Watir
23
+
24
+ * Generating a framework with Rspec and Watir
25
+
26
+ * Generating a framework with Rspec and Appium for IOS
27
+
28
+ * Generating a framework with Cucumber and Appium for IOS
21
29
 
22
30
  In order to run the appium tests, download the example [app](https://github.com/cloudgrey-io/the-app/releases/tag/v1.10.0)
23
31
 
@@ -25,25 +33,28 @@ This works in all the platforms (Tested on Mac OS, Linux and Windows)
25
33
 
26
34
  **Ruby raider provides the following list of commands**
27
35
  ```
28
- raider browser [BROWSER] # Sets the default browser for a project
29
-
30
- raider feature [FEATURE_NAME] # Creates a new feature
36
+ Commands:
37
+ raider browser [BROWSER] # Sets the default browser for a project
38
+
39
+ raider feature [FEATURE_NAME] # Creates a new feature
40
+
41
+ raider help [COMMAND] # Describe available commands or one specific command
31
42
 
32
- raider help [COMMAND] # Describe available commands or one specific command
43
+ raider helper [HELPER_NAME] # Creates a new helper
33
44
 
34
- raider helper [HELPER_NAME] # Creates a new helper
45
+ raider new [PROJECT_NAME] # Creates a new framework based on settings picked
35
46
 
36
- raider new [PROJECT_NAME] # Creates a new framework based on settings picked
47
+ raider page [PAGE_NAME] # Creates a new page object
37
48
 
38
- raider page [PAGE_NAME] # Creates a new page object
49
+ raider path [PATH] # Sets the default path for scaffolding
39
50
 
40
- raider path [PATH] # Sets the default path for scaffolding
51
+ raider raid # It runs all the tests in a project
41
52
 
42
- raider raid # It runs all the tests in a project
53
+ raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
43
54
 
44
- raider spec [SPEC_NAME] # Creates a new spec
55
+ raider spec [SPEC_NAME] # Creates a new spec
45
56
 
46
- raider url [URL] # Sets the default url for a project
57
+ raider url [URL] # Sets the default url for a project
47
58
  ```
48
59
 
49
60
  It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
data/Rakefile CHANGED
@@ -12,4 +12,4 @@ desc 'Create a page'
12
12
  task :page, [:name] do |_t, args|
13
13
  RubyRaider.start
14
14
  RubyRaider.page(args.page)
15
- end
15
+ end
@@ -12,32 +12,30 @@ class AutomationGenerator < Generator
12
12
  end
13
13
 
14
14
  def generate_home_page
15
- if @_initializer.first.include?('appium_ios')
16
- template('automation/home_page.tt', "#{name}/page_objects/pages/home_page.rb")
17
- end
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
- unless @_initializer.first.include?('appium_ios')
22
- template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
23
- end
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
- unless @_initializer.first.include?('appium_ios')
28
- template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
29
- end
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
- if @_initializer.first.include?('appium_ios')
34
- template('automation/confirmation_page.tt', "#{name}/page_objects/pages/confirmation_page.rb")
35
- end
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
@@ -27,4 +27,3 @@ class CommonGenerator < Generator
27
27
  empty_directory "#{name}/allure-results/screenshots"
28
28
  end
29
29
  end
30
-
@@ -15,4 +15,3 @@ class CucumberGenerator < Generator
15
15
  template('cucumber/env.tt', "#{name}/features/support/env.rb")
16
16
  end
17
17
  end
18
-
@@ -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__) + '/templates'
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
- if @_initializer.first.include?('selenium')
29
- template('helpers/selenium_helper.tt', "#{name}/helpers/selenium_helper.rb")
30
- end
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
- unless @_initializer.first.include?('watir')
35
- template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
36
- end
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
-
@@ -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.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
@@ -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 "new [PROJECT_NAME]", "Creates a new framework based on settings picked"
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 "page [PAGE_NAME]", "Creates a new page object"
17
+ desc 'page [PAGE_NAME]', 'Creates a new page object'
15
18
  option :path,
16
- :type => :string, :required => false, :desc => 'The path where your page will be created', :aliases => '-p'
19
+ type: :string, required: false, desc: 'The path where your page will be created', aliases: '-p'
17
20
  option :delete,
18
- :type => :boolean, :required => false, :desc => 'This will delete the selected page', :aliases => '-d'
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 "feature [FEATURE_NAME]", "Creates a new feature"
33
+ desc 'feature [FEATURE_NAME]', 'Creates a new feature'
30
34
  option :path,
31
- :type => :string, :required => false, :desc => 'The path where your feature will be created', :aliases => '-p'
35
+ type: :string, required: false, desc: 'The path where your feature will be created', aliases: '-p'
32
36
  option :delete,
33
- :type => :boolean, :required => false, :desc => 'This will delete the selected feature', :aliases => '-d'
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 "spec [SPEC_NAME]", "Creates a new spec"
49
+ desc 'spec [SPEC_NAME]', 'Creates a new spec'
45
50
  option :path,
46
- :type => :string, :required => false, :desc => 'The path where your spec will be created', :aliases => '-p'
51
+ type: :string, required: false, desc: 'The path where your spec will be created', aliases: '-p'
47
52
  option :delete,
48
- :type => :boolean, :required => false, :desc => 'This will delete the selected spec', :aliases => '-d'
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,12 +60,13 @@ class RubyRaider < Thor
55
60
  Scaffolding.new([name, path]).generate_spec
56
61
  end
57
62
  end
63
+ map '-s' => "spec"
58
64
 
59
- desc "helper [HELPER_NAME]", "Creates a new helper"
65
+ desc 'helper [HELPER_NAME]', 'Creates a new helper'
60
66
  option :path,
61
- :type => :string, :required => false, :desc => 'The path where your helper will be created', :aliases => '-p'
67
+ type: :string, required: false, desc: 'The path where your helper will be created', aliases: '-p'
62
68
  option :delete,
63
- :type => :boolean, :required => false, :desc => 'This will delete the selected helper', :aliases => '-d'
69
+ type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d'
64
70
 
65
71
  def helper(name)
66
72
  path = options[:path].nil? ? load_config_path('helper') : options[:path]
@@ -70,36 +76,73 @@ class RubyRaider < Thor
70
76
  Scaffolding.new([name, path]).generate_helper
71
77
  end
72
78
  end
79
+ map '-h' => "helper"
73
80
 
74
- desc "path [PATH]", "Sets the default path for scaffolding"
81
+ desc 'path [PATH]', 'Sets the default path for scaffolding'
75
82
  option :feature,
76
- :type => :boolean, :required => false, :desc => 'The default path for your features', :aliases => '-f'
83
+ type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
77
84
  option :helper,
78
- :type => :boolean, :required => false, :desc => 'The default path for your helpers', :aliases => '-h'
85
+ type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
79
86
  option :spec,
80
- :type => :boolean, :required => false, :desc => 'The default path for your specs', :aliases => '-s'
87
+ type: :boolean, required: false, desc: 'The default path for your specs', aliases: '-s'
81
88
  def path(default_path)
82
89
  type = options.empty? ? 'page' : options.keys.first
83
90
  Utilities.new.send("#{type}_path=", default_path)
84
91
  end
92
+ map '-p' => "path"
85
93
 
86
- desc "url [URL]", "Sets the default url for a project"
94
+ desc 'url [URL]', 'Sets the default url for a project'
87
95
 
88
96
  def url(default_url)
89
97
  Utilities.new.url = default_url
90
98
  end
99
+ map '-u' => "url"
91
100
 
92
- desc "browser [BROWSER]", "Sets the default browser for a project"
93
-
94
- def browser(default_browser)
95
- Utilities.new.browser = default_browser
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]
96
110
  end
111
+ map '-b' => "browser"
97
112
 
98
- desc "raid", "It runs all the tests in a project"
99
-
113
+ desc 'raid', 'It runs all the tests in a project'
100
114
  def raid
101
115
  Utilities.new.run
102
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"
103
146
 
104
147
  no_commands do
105
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__) + '/templates'
12
+ "#{File.dirname(__FILE__)}/templates"
11
13
  end
12
14
 
13
15
  def generate_class
@@ -26,6 +28,11 @@ class Scaffolding < Thor::Group
26
28
  template('helper.tt', default_path("helpers/#{name}_helper.rb", '_helper.rb'))
27
29
  end
28
30
 
31
+ def generate_config
32
+ template('../../generators/templates/common/config.tt',
33
+ default_path("config/config.yml", '.yml'))
34
+ end
35
+
29
36
  def delete_class
30
37
  remove_file(default_path("page_objects/pages/#{name}_page.rb", '_page.rb'))
31
38
  end
@@ -42,6 +49,10 @@ class Scaffolding < Thor::Group
42
49
  remove_file(default_path("helpers/#{name}_helper.rb", '_helper.rb'))
43
50
  end
44
51
 
52
+ def delete_config
53
+ remove_file(default_path("config/config.yml", '.yml'))
54
+ end
55
+
45
56
  def default_path(standard_path, file_type)
46
57
  path.nil? ? standard_path : "#{path}/#{name}#{file_type}"
47
58
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  class Utilities
@@ -36,6 +38,16 @@ class Utilities
36
38
  overwrite_yaml
37
39
  end
38
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
+
39
51
  def run
40
52
  if File.directory? 'spec'
41
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.2'
5
+ s.version = '0.3.5'
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'
@@ -155,7 +155,7 @@ describe RubyRaider do
155
155
 
156
156
  context 'updates the config file' do
157
157
  before(:all) do
158
- CommonGenerator.new(%w[rspec cucumber test]).invoke(:generate_config_file)
158
+ CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
159
159
  FileUtils.cp_lr('test/config', './')
160
160
  end
161
161
 
@@ -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|
@@ -178,4 +204,36 @@ describe RubyRaider do
178
204
  end
179
205
  end
180
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
181
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.2
4
+ version: 0.3.5
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-04 00:00:00.000000000 Z
11
+ date: 2022-06-17 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: rubocop
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.27'
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: '1.27'
54
+ version: 3.11.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: rubocop-rspec
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.9.0
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: 2.9.0
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: 3.11.0
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: 3.11.0
82
+ version: 2.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: highline
85
85
  requirement: !ruby/object:Gem::Requirement