ruby_raider 0.4.2 → 0.4.3

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/lib/commands/utility_commands.rb +8 -0
  4. data/lib/generators/automation_generator.rb +7 -7
  5. data/lib/generators/common_generator.rb +2 -0
  6. data/lib/generators/cucumber_generator.rb +1 -1
  7. data/lib/generators/helper_generator.rb +6 -0
  8. data/lib/generators/menu_generator.rb +1 -1
  9. data/lib/generators/rspec_generator.rb +2 -2
  10. data/lib/generators/templates/automation/abstract_page.tt +4 -0
  11. data/lib/generators/templates/automation/appium_caps.tt +7 -0
  12. data/lib/generators/templates/automation/home_page.tt +1 -5
  13. data/lib/generators/templates/automation/partials/android_caps.tt +5 -0
  14. data/lib/generators/templates/automation/partials/cross_platform_caps.tt +14 -0
  15. data/lib/generators/templates/automation/partials/home_page_selector.tt +8 -0
  16. data/lib/generators/templates/automation/partials/ios_caps.tt +6 -0
  17. data/lib/generators/templates/automation/partials/pdp_page_selector.tt +8 -0
  18. data/lib/generators/templates/automation/pdp_page.tt +1 -5
  19. data/lib/generators/templates/common/config.tt +5 -2
  20. data/lib/generators/templates/common/partials/mobile_config.tt +1 -0
  21. data/lib/generators/templates/common/partials/web_config.tt +2 -0
  22. data/lib/generators/templates/common/read_me.tt +4 -0
  23. data/lib/generators/templates/helpers/appium_helper.tt +29 -0
  24. data/lib/generators/templates/helpers/driver_helper.tt +15 -2
  25. data/lib/generators/templates/helpers/partials/driver_and_options.tt +8 -5
  26. data/lib/generators/templates/helpers/raider_helper.tt +3 -0
  27. data/lib/utilities/utilities.rb +5 -0
  28. data/ruby_raider.gemspec +1 -1
  29. data/spec/automation_generator_spec.rb +10 -6
  30. data/spec/common_generator_spec.rb +44 -6
  31. data/spec/cucumber_generator_spec.rb +5 -1
  32. data/spec/helpers_generator_spec.rb +26 -6
  33. data/spec/rspec_generator_spec.rb +5 -1
  34. data/spec/spec_helper.rb +1 -1
  35. metadata +11 -5
  36. data/lib/generators/templates/automation/appium_settings.tt +0 -5
  37. data/lib/generators/templates/automation/partials/android_settings.tt +0 -8
  38. data/lib/generators/templates/automation/partials/ios_settings.tt +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a92cf556575579c0fd4b96bde582b6f19d0715224467dae8276a7b5a367d611
4
- data.tar.gz: c4327f646e1f7dc87657da33e7cf2a075103fe605a953cb9e0a2c4f0a8bef24f
3
+ metadata.gz: 1179dcf5f2664b6adea02db8af1b33883f18d095f9c9b57acf3fa2bb56d68c49
4
+ data.tar.gz: ad8dc4b695f154191047406e882029b063c4147987adf369c018063d38b414c9
5
5
  SHA512:
6
- metadata.gz: cd2a91f76d5f338b7cd2e79ae0c3af2012a4ff4a46802c3f90b8d1e79724c30fb9127790a89ceac5592ac74e039863993f62c7205e732fa714b3a3ae4309c4e3
7
- data.tar.gz: d61169f5255b2f0e12a9cd62cb312c81dabc696ad9285d0863c62d46cdaaa4e9cea152e68985ff063450fc0c9c5d55cf752f5d06ae4cf245647c0ce924906ec9
6
+ metadata.gz: d052c0513c67e27313cdcff208ab5ed54a6606722480ab3534b2c84976b0fffd0a8675367b278575ec1181b7a48f695ed08643cee5bf5229c317c136359fc171
7
+ data.tar.gz: 1130758fd998eecfb68f320968c3993ea5d026c362ebcc22068ae28c4b0301084e0fb9b6d116a8e2f06e14cecba91b25d37d0e4d81595a1e565cc3917c3de512
data/README.md CHANGED
@@ -47,6 +47,10 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
47
47
 
48
48
  * Generating a framework with Cucumber and Appium for Android
49
49
 
50
+ * Generating a framework with Rspec and Appium cross platform
51
+
52
+ * Generating a framework with Cucumber and Appium cross platform
53
+
50
54
  ***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
51
55
 
52
56
  This works in all the platforms (Tested on Mac OS, Linux and Windows).
@@ -92,6 +96,8 @@ Commands:
92
96
  raider page [PAGE_NAME] # Creates a new page object
93
97
 
94
98
  raider path [PATH] # Sets the default path for scaffolding
99
+
100
+ raider platform [PLATFORM] # Sets the default platform for a cross-platform project
95
101
 
96
102
  raider raid # Runs all the tests in a project
97
103
 
@@ -72,4 +72,12 @@ class UtilityCommands < Thor
72
72
  type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
73
73
  option :delete,
74
74
  type: :boolean, required: false, desc: 'This will delete the selected config file', aliases: '-d'
75
+
76
+ desc 'platform [platform]', 'Sets the default platform for a cross-platform project'
77
+
78
+ def platform(platform)
79
+ Utilities.new.platform = platform
80
+ end
81
+
82
+ map '-pl' => 'platform'
75
83
  end
@@ -4,7 +4,7 @@ require_relative 'generator'
4
4
 
5
5
  class AutomationGenerator < Generator
6
6
  def generate_login_page
7
- return unless (@_initializer.first & %w[android ios]).empty?
7
+ return unless (@_initializer.first & %w[android ios cross_platform]).empty?
8
8
 
9
9
  template('automation/login_page.tt', "#{name}/page_objects/pages/login_page.rb")
10
10
  end
@@ -14,32 +14,32 @@ class AutomationGenerator < Generator
14
14
  end
15
15
 
16
16
  def generate_home_page
17
- return if (@_initializer.first & %w[android ios]).empty?
17
+ return if (@_initializer.first & %w[android ios cross_platform]).empty?
18
18
 
19
19
  template('automation/home_page.tt', "#{name}/page_objects/pages/home_page.rb")
20
20
  end
21
21
 
22
22
  def generate_pdp_page
23
- return if (@_initializer.first & %w[android ios]).empty?
23
+ return if (@_initializer.first & %w[android ios cross_platform]).empty?
24
24
 
25
25
  template('automation/pdp_page.tt', "#{name}/page_objects/pages/pdp_page.rb")
26
26
  end
27
27
 
28
28
  def generate_header_component
29
- return unless (@_initializer.first & %w[android ios]).empty?
29
+ return unless (@_initializer.first & %w[android ios cross_platform]).empty?
30
30
 
31
31
  template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
32
32
  end
33
33
 
34
34
  def generate_abstract_component
35
- return unless (@_initializer.first & %w[android ios]).empty?
35
+ return unless (@_initializer.first & %w[android ios cross_platform]).empty?
36
36
 
37
37
  template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
38
38
  end
39
39
 
40
40
  def generate_appium_settings
41
- return if (@_initializer.first & %w[android ios]).empty?
41
+ return if (@_initializer.first & %w[android ios cross_platform]).empty?
42
42
 
43
- template('automation/appium_settings.tt', "#{name}/appium.txt")
43
+ template('automation/appium_caps.tt', "#{name}/config/capabilities.yml")
44
44
  end
45
45
  end
@@ -8,6 +8,8 @@ class CommonGenerator < Generator
8
8
  end
9
9
 
10
10
  def generate_config_file
11
+ return unless (@_initializer.first & %w[android ios]).empty?
12
+
11
13
  template('common/config.tt', "#{name}/config/config.yml")
12
14
  end
13
15
 
@@ -20,6 +20,6 @@ class CucumberGenerator < Generator
20
20
  end
21
21
 
22
22
  def template_name
23
- @template_name ||= (@_initializer.first & %w[android ios]).empty? ? 'login' : 'home'
23
+ @template_name ||= (@_initializer.first & %w[android ios cross_platform]).empty? ? 'login' : 'home'
24
24
  end
25
25
  end
@@ -30,4 +30,10 @@ class HelpersGenerator < Generator
30
30
 
31
31
  template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
32
32
  end
33
+
34
+ def generate_pdp_page
35
+ return unless (@_initializer.first.include?('cross_platform'))
36
+
37
+ template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
38
+ end
33
39
  end
@@ -40,7 +40,7 @@ class MenuGenerator
40
40
  prompt.select('Please select your mobile platform') do |menu|
41
41
  menu.choice :iOS, -> { choose_test_framework 'ios' }
42
42
  menu.choice :Android, -> { choose_test_framework 'android' }
43
- menu.choice :Cross_Platform, -> { error_handling('Cross Platform') }
43
+ menu.choice :Cross_Platform, -> { choose_test_framework 'cross_platform' }
44
44
  menu.choice :Quit, -> { exit }
45
45
  end
46
46
  end
@@ -4,13 +4,13 @@ require_relative 'generator'
4
4
 
5
5
  class RspecGenerator < Generator
6
6
  def generate_login_spec
7
- return unless (@_initializer.first & %w[android ios]).empty?
7
+ return unless (@_initializer.first & %w[android ios cross_platform]).empty?
8
8
 
9
9
  template('rspec/spec.tt', "#{name}/spec/login_page_spec.rb")
10
10
  end
11
11
 
12
12
  def generate_pdp_spec
13
- return if (@_initializer.first & %w[android ios]).empty?
13
+ return if (@_initializer.first & %w[android ios cross_platform]).empty?
14
14
 
15
15
  template('rspec/spec.tt', "#{name}/spec/pdp_page_spec.rb")
16
16
  end
@@ -1,6 +1,10 @@
1
1
  <%= ERB.new(File.read(File.expand_path('./partials/require_raider.tt', __dir__)), nil, '-').result(binding) -%>
2
2
 
3
3
  class AbstractPage
4
+ <% if automation == 'cross_platform' %>
5
+ include Raider::AppiumHelper
6
+ <% end %>
7
+
4
8
  <%= ERB.new(File.read(File.expand_path('./partials/initialize_selector.tt', __dir__))).result(binding) -%>
5
9
  <%= ERB.new(File.read(File.expand_path('./partials/visit_method.tt', __dir__))).result(binding) -%>
6
10
  <%= ERB.new(File.read(File.expand_path('./partials/url_methods.tt', __dir__))).result(binding) -%>
@@ -0,0 +1,7 @@
1
+ <% if automation == 'ios' %>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/ios_caps.tt', __dir__))).result(binding) -%>
3
+ <% elsif automation == 'android' %>
4
+ <%= ERB.new(File.read(File.expand_path('./partials/android_caps.tt', __dir__))).result(binding) -%>
5
+ <% else %>
6
+ <%= ERB.new(File.read(File.expand_path('./partials/cross_platform_caps.tt', __dir__))).result(binding) -%>
7
+ <% end %>
@@ -15,10 +15,6 @@ class HomePage < AbstractPage
15
15
  # Elements
16
16
 
17
17
  def backpack_image
18
- <% if automation == 'ios' %>
19
- driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
20
- <% else %>
21
- driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
22
- <% end %>
18
+ <%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__))).result(binding) %>
23
19
  end
24
20
  end
@@ -0,0 +1,5 @@
1
+ automationName: UiAutomator2
2
+ platformName: Android
3
+ deviceName: Nexus_7_API_33
4
+ app: "Android-MyDemoAppRN.1.3.0.build-244.apk"
5
+ autoGrantPermissions: true
@@ -0,0 +1,14 @@
1
+ android:
2
+ automationName: UiAutomator2
3
+ platformName: Android
4
+ deviceName: Nexus_7_API_33
5
+ app: "Android-MyDemoAppRN.1.3.0.build-244.apk"
6
+ autoGrantPermissions: true
7
+
8
+ ios:
9
+ automationName: XCUITest
10
+ platformName: iOS
11
+ platformVersion: "15.5"
12
+ deviceName: iPhone 11
13
+ app: "MyRNDemoApp.app"
14
+ autoDismissAlerts: true
@@ -0,0 +1,8 @@
1
+ <% if automation == 'ios' %>
2
+ driver.find_element(predicate: 'label == "Sauce Labs Backpack"')
3
+ <% elsif automation == 'android' %>
4
+ driver.find_element(xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]')
5
+ <% else %>
6
+ element(ios: { predicate: 'label == "Sauce Labs Backpack"' },
7
+ android: { xpath: '(//android.view.ViewGroup[@content-desc="store item"])[1]/android.view.ViewGroup[1]' })
8
+ <% end %>
@@ -0,0 +1,6 @@
1
+ automationName: XCUITest
2
+ platformName: iOS
3
+ platformVersion: "15.5"
4
+ deviceName: iPhone 11
5
+ app: "MyRNDemoApp.app"
6
+ autoDismissAlerts: true
@@ -0,0 +1,8 @@
1
+ <% if automation == 'ios' %>
2
+ driver.find_element(accessibility_id: 'Add To Cart button')
3
+ <% elsif automation == 'android' %>
4
+ driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
5
+ <% else %>
6
+ element(ios: { accessibility_id: 'Add To Cart button' },
7
+ android: { xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView' })
8
+ <% end %>
@@ -13,10 +13,6 @@ class PdpPage < AbstractPage
13
13
  # Elements
14
14
 
15
15
  def add_to_cart_button
16
- <% if automation == 'ios' %>
17
- driver.find_element(accessibility_id: 'Add To Cart button')
18
- <% else %>
19
- driver.find_element(xpath: '//android.view.ViewGroup[@content-desc="Add To Cart button"]/android.widget.TextView')
20
- <% end %>
16
+ <%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__))).result(binding) %>
21
17
  end
22
18
  end
@@ -1,2 +1,5 @@
1
- browser: :chrome
2
- url: 'https://automationteststore.com/'
1
+ <% if %w[ios android cross_platform].include?(automation) -%>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/mobile_config.tt', __dir__))).result(binding) %>
3
+ <% else -%>
4
+ <%= ERB.new(File.read(File.expand_path('./partials/web_config.tt', __dir__))).result(binding) %>
5
+ <% end -%>
@@ -0,0 +1 @@
1
+ platform: :ios
@@ -0,0 +1,2 @@
1
+ browser: :chrome
2
+ url: 'https://automationteststore.com/'
@@ -18,6 +18,8 @@ Currently we only support:
18
18
  * Gerating a Selenium with both Cucumber and Rspec framework
19
19
  * Gerating a Watir with both Cucumber and Rspec framework
20
20
  * Generating an Appium project with Rspec and Cucumber on IOS
21
+ * Generating an Appium project with Rspec and Cucumber on Android
22
+ * Generating an Appium project with Rspec and Cucumber cross platform
21
23
 
22
24
  In order to run the appium tests, download the example [app](https://github.com/cloudgrey-io/the-app/releases/tag/v1.10.0)
23
25
 
@@ -40,6 +42,8 @@ Commands:
40
42
 
41
43
  raider path [PATH] # Sets the default path for scaffolding
42
44
 
45
+ raider platform [PLATFORM] # Sets the default platform for a cross-platform project
46
+
43
47
  raider raid # It runs all the tests in a project
44
48
 
45
49
  raider scaffold [SCAFFOLD_NAME] # It generates everything needed to start automating
@@ -0,0 +1,29 @@
1
+ module Raider
2
+ module AppiumHelper
3
+ def element(opts = {})
4
+ return driver.find_element(strategy(opts) => selector(opts)) if opts[os]
5
+
6
+ driver.find_element(opts)
7
+ end
8
+
9
+ def elements(opts = {})
10
+ return driver.find_elements(strategy(opts) => selector(opts)) if opts[os]
11
+
12
+ driver.find_elements(opts)
13
+ end
14
+
15
+ def os
16
+ driver.appium_device
17
+ end
18
+
19
+ private
20
+
21
+ def strategy(opts)
22
+ opts[os].keys.first
23
+ end
24
+
25
+ def selector(opts)
26
+ opts[os][strategy(opts)]
27
+ end
28
+ end
29
+ end
@@ -9,8 +9,21 @@ require 'appium_lib'
9
9
 
10
10
  module Raider
11
11
  module DriverHelper
12
- attr_reader :driver
12
+ attr_reader :driver
13
13
 
14
- <%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__))).result(binding).strip! %>
14
+ <%= ERB.new(File.read(File.expand_path('./partials/driver_and_options.tt', __dir__))).result(binding).strip! %>
15
+
16
+ <% if automation == 'cross_platform' -%>
17
+ private
18
+
19
+ def config
20
+ YAML.load_file('config/config.yml')
21
+ end
22
+ <% end -%>
23
+ <% if automation != 'selenium' -%>
24
+ def caps
25
+ YAML.load_file('config/capabilities.yml')
26
+ end
27
+ <% end -%>
15
28
  end
16
29
  end
@@ -16,10 +16,13 @@
16
16
  opts.each {|option| caps.add_argument(option) }
17
17
  caps
18
18
  end
19
+ <% elsif automation == 'cross_platform' %>
20
+ def new_driver
21
+ platform = config['platform'].to_s
22
+ @driver = Appium::Driver.new({ caps: caps[platform] })
23
+ end
19
24
  <% else %>
20
- def new_driver
21
- appium_file = File.join(Dir.pwd, 'appium.txt')
22
- caps = Appium.load_appium_txt(file: appium_file)
23
- @driver = Appium::Driver.new(caps)
24
- end
25
+ def new_driver
26
+ @driver = Appium::Driver.new({ caps: caps })
27
+ end
25
28
  <% end %>
@@ -11,4 +11,7 @@ module Raider
11
11
  require_relative 'driver_helper'
12
12
  <% end -%>
13
13
  require_relative 'allure_helper'
14
+ <% if automation == 'cross_platform' -%>
15
+ require_relative 'appium_helper'
16
+ <% end -%>
14
17
  end
@@ -38,6 +38,11 @@ class Utilities
38
38
  overwrite_yaml
39
39
  end
40
40
 
41
+ def platform=(platform)
42
+ @config['platform'] = platform
43
+ overwrite_yaml
44
+ end
45
+
41
46
  def browser_options=(*opts)
42
47
  @config['browser_options'] = opts.flatten
43
48
  overwrite_yaml
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.4.2'
5
+ s.version = '0.4.3'
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']
@@ -34,10 +34,6 @@ describe AutomationGenerator do
34
34
  it 'creates a pdp page file' do
35
35
  expect(File).to exist("#{name}/page_objects/pages/pdp_page.rb")
36
36
  end
37
-
38
- it 'creates an appium config file' do
39
- expect(File).to exist("#{name}/appium.txt")
40
- end
41
37
  end
42
38
 
43
39
  context 'with rspec and selenium' do
@@ -45,7 +41,7 @@ describe AutomationGenerator do
45
41
  end
46
42
 
47
43
  context 'with rspec and watir' do
48
- include_examples 'creates web automation files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
44
+ include_examples 'creates web automation files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
49
45
  end
50
46
 
51
47
  context 'with cucumber and selenium' do
@@ -53,7 +49,7 @@ describe AutomationGenerator do
53
49
  end
54
50
 
55
51
  context 'with cucumber and watir' do
56
- include_examples 'creates web automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
52
+ include_examples 'creates web automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
57
53
  end
58
54
 
59
55
  context 'with rspec and appium android' do
@@ -71,4 +67,12 @@ describe AutomationGenerator do
71
67
  context 'with cucumber and appium ios' do
72
68
  include_examples 'creates mobile automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
73
69
  end
70
+
71
+ context 'with cucumber and appium cross platform' do
72
+ include_examples 'creates mobile automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
73
+ end
74
+
75
+ context 'with cucumber and appium cross platform' do
76
+ include_examples 'creates mobile automation files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
77
+ end
74
78
  end
@@ -5,10 +5,6 @@ require_relative 'spec_helper'
5
5
 
6
6
  describe CommonGenerator do
7
7
  shared_examples 'creates common files' do |name|
8
- it 'creates a config file' do
9
- expect(File).to exist("#{name}/config/config.yml")
10
- end
11
-
12
8
  it 'creates a rake file' do
13
9
  expect(File).to exist("#{name}/Rakefile")
14
10
  end
@@ -22,35 +18,77 @@ describe CommonGenerator do
22
18
  end
23
19
  end
24
20
 
21
+ shared_examples 'creates a config file' do |name|
22
+ it 'creates a config file' do
23
+ expect(File).to exist("#{name}/config/config.yml")
24
+ end
25
+ end
26
+
27
+ shared_examples 'creates a capabilities file' do |name|
28
+ it 'creates a config file' do
29
+ expect(File).to exist("#{name}/config/capabilities.yml")
30
+ end
31
+ end
32
+
33
+ shared_examples "doesn't create a config file" do |name|
34
+ it "doesn't create a config file" do
35
+ expect(File).to_not exist("#{name}/config/config.yml")
36
+ end
37
+ end
38
+
25
39
  context 'with rspec and selenium' do
26
40
  include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
41
+ include_examples 'creates a config file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
27
42
  end
28
43
 
29
44
  context 'with rspec and watir' do
30
- include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
45
+ include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
46
+ include_examples 'creates a config file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
31
47
  end
32
48
 
33
49
  context 'with cucumber and selenium' do
34
50
  include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
51
+ include_examples 'creates a config file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
35
52
  end
36
53
 
37
54
  context 'with cucumber and watir' do
38
- include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
55
+ include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
56
+ include_examples 'creates a config file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
39
57
  end
40
58
 
41
59
  context 'with rspec and appium android' do
42
60
  include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.first}"
61
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.first}"
62
+ include_examples "doesn't create a config file", "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.first}"
43
63
  end
44
64
 
45
65
  context 'with rspec and appium ios' do
46
66
  include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[1]}"
67
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[1]}"
68
+ include_examples "doesn't create a config file", "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[1]}"
47
69
  end
48
70
 
49
71
  context 'with cucumber and appium android' do
50
72
  include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.first}"
73
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.first}"
74
+ include_examples "doesn't create a config file", "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.first}"
51
75
  end
52
76
 
53
77
  context 'with cucumber and appium ios' do
54
78
  include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
79
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
80
+ include_examples "doesn't create a config file", "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
81
+ end
82
+
83
+ context 'with cucumber and appium cross platform' do
84
+ include_examples 'creates common files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
85
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
86
+ include_examples 'creates a config file', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
87
+ end
88
+
89
+ context 'with rspec and appium cross platform' do
90
+ include_examples 'creates common files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
91
+ include_examples 'creates a capabilities file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
92
+ include_examples 'creates a config file', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
55
93
  end
56
94
  end
@@ -30,11 +30,15 @@ describe CucumberGenerator do
30
30
  include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}", 'home'
31
31
  end
32
32
 
33
+ context 'with cucumber and appium cross platform' do
34
+ include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}", 'home'
35
+ end
36
+
33
37
  context 'with cucumber and selenium' do
34
38
  include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}", 'login'
35
39
  end
36
40
 
37
41
  context 'with cucumber and watir' do
38
- include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}", 'login'
42
+ include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}", 'login'
39
43
  end
40
44
  end
@@ -38,6 +38,12 @@ describe HelpersGenerator do
38
38
  end
39
39
  end
40
40
 
41
+ shared_examples 'creates cross platform helpers' do |name|
42
+ it 'creates a browser helper file' do
43
+ expect(File).to exist("#{name}/helpers/appium_helper.rb")
44
+ end
45
+ end
46
+
41
47
  context 'with rspec and selenium' do
42
48
  include_examples 'creates common helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
43
49
  include_examples 'creates selenium helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
@@ -45,9 +51,9 @@ describe HelpersGenerator do
45
51
  end
46
52
 
47
53
  context 'with rspec and watir' do
48
- include_examples 'creates common helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
49
- include_examples 'creates watir helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
50
- include_examples 'creates rspec helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
54
+ include_examples 'creates common helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
55
+ include_examples 'creates watir helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
56
+ include_examples 'creates rspec helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
51
57
  end
52
58
 
53
59
  context 'with cucumber and selenium' do
@@ -57,9 +63,9 @@ describe HelpersGenerator do
57
63
  end
58
64
 
59
65
  context 'with cucumber and watir' do
60
- include_examples 'creates common helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
61
- include_examples 'creates watir helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
62
- include_examples 'creates cucumber helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
66
+ include_examples 'creates common helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
67
+ include_examples 'creates watir helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
68
+ include_examples 'creates cucumber helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
63
69
  end
64
70
 
65
71
  context 'with rspec and appium android' do
@@ -85,4 +91,18 @@ describe HelpersGenerator do
85
91
  include_examples 'creates selenium helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
86
92
  include_examples 'creates cucumber helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[1]}"
87
93
  end
94
+
95
+ context 'with rspec and appium cross platform' do
96
+ include_examples 'creates common helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
97
+ include_examples 'creates selenium helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
98
+ include_examples 'creates rspec helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
99
+ include_examples 'creates cross platform helpers', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}"
100
+ end
101
+
102
+ context 'with cucumber and appium cross platform' do
103
+ include_examples 'creates common helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
104
+ include_examples 'creates selenium helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
105
+ include_examples 'creates cucumber helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
106
+ include_examples 'creates cross platform helpers', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
107
+ end
88
108
  end
@@ -19,7 +19,7 @@ describe RspecGenerator do
19
19
  end
20
20
 
21
21
  context 'with rspec and watir' do
22
- include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}", 'login'
22
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}", 'login'
23
23
  end
24
24
 
25
25
  context 'with rspec and appium android' do
@@ -29,4 +29,8 @@ describe RspecGenerator do
29
29
  context 'with rspec and appium ios' do
30
30
  include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[1]}", 'pdp'
31
31
  end
32
+
33
+ context 'with rspec and appium cross platform' do
34
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}", 'pdp'
35
+ end
32
36
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  require 'rspec'
5
5
  require_relative '../lib/generators/menu_generator'
6
6
 
7
- AUTOMATION_TYPES = %w[android ios selenium watir].freeze
7
+ AUTOMATION_TYPES = %w[android ios selenium watir cross_platform].freeze
8
8
  FRAMEWORKS = %w[cucumber rspec].freeze
9
9
 
10
10
  RSpec.configure do |config|
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.4.2
4
+ version: 0.4.3
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-10-24 00:00:00.000000000 Z
11
+ date: 2022-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -155,14 +155,17 @@ files:
155
155
  - lib/generators/rspec_generator.rb
156
156
  - lib/generators/templates/automation/abstract_component.tt
157
157
  - lib/generators/templates/automation/abstract_page.tt
158
- - lib/generators/templates/automation/appium_settings.tt
158
+ - lib/generators/templates/automation/appium_caps.tt
159
159
  - lib/generators/templates/automation/component.tt
160
160
  - lib/generators/templates/automation/home_page.tt
161
161
  - lib/generators/templates/automation/login_page.tt
162
- - lib/generators/templates/automation/partials/android_settings.tt
162
+ - lib/generators/templates/automation/partials/android_caps.tt
163
+ - lib/generators/templates/automation/partials/cross_platform_caps.tt
163
164
  - lib/generators/templates/automation/partials/element.tt
165
+ - lib/generators/templates/automation/partials/home_page_selector.tt
164
166
  - lib/generators/templates/automation/partials/initialize_selector.tt
165
- - lib/generators/templates/automation/partials/ios_settings.tt
167
+ - lib/generators/templates/automation/partials/ios_caps.tt
168
+ - lib/generators/templates/automation/partials/pdp_page_selector.tt
166
169
  - lib/generators/templates/automation/partials/require_raider.tt
167
170
  - lib/generators/templates/automation/partials/selenium_login.tt
168
171
  - lib/generators/templates/automation/partials/url_methods.tt
@@ -172,6 +175,8 @@ files:
172
175
  - lib/generators/templates/common/config.tt
173
176
  - lib/generators/templates/common/gemfile.tt
174
177
  - lib/generators/templates/common/partials/automation_gems.tt
178
+ - lib/generators/templates/common/partials/mobile_config.tt
179
+ - lib/generators/templates/common/partials/web_config.tt
175
180
  - lib/generators/templates/common/rakefile.tt
176
181
  - lib/generators/templates/common/read_me.tt
177
182
  - lib/generators/templates/cucumber/env.tt
@@ -186,6 +191,7 @@ files:
186
191
  - lib/generators/templates/cucumber/steps.tt
187
192
  - lib/generators/templates/cucumber/world.tt
188
193
  - lib/generators/templates/helpers/allure_helper.tt
194
+ - lib/generators/templates/helpers/appium_helper.tt
189
195
  - lib/generators/templates/helpers/browser_helper.tt
190
196
  - lib/generators/templates/helpers/driver_helper.tt
191
197
  - lib/generators/templates/helpers/partials/allure_imports.tt
@@ -1,5 +0,0 @@
1
- <% if automation == 'ios' %>
2
- <%= ERB.new(File.read(File.expand_path('./partials/ios_settings.tt', __dir__))).result(binding) -%>
3
- <% else %>
4
- <%= ERB.new(File.read(File.expand_path('./partials/android_settings.tt', __dir__))).result(binding) -%>
5
- <% end %>
@@ -1,8 +0,0 @@
1
- [caps]
2
- automationName = "UiAutomator2"
3
- platformName = "Android"
4
- deviceName = "Nexus_7_API_33"
5
- app = "Android-MyDemoAppRN.1.3.0.build-244.apk"
6
-
7
- [appium_lib]
8
- server_url = "http://127.0.0.1:4723/wd/hub"
@@ -1,8 +0,0 @@
1
- [caps]
2
- platformName = "iOS"
3
- platformVersion = "16.0"
4
- deviceName = "iPhone SE (3rd generation)"
5
- app = "MyRNDemoApp.app"
6
-
7
- [appium_lib]
8
- server_url = "http://127.0.0.1:4723/wd/hub"