ruby_raider 0.4.4 → 0.4.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: 36188ec04973b3250dce20a65362ad77cd87c6f5aa255977f66d024ebdf40d65
4
- data.tar.gz: d7c704bf859d9ac8e73fd76260565545a65eb48d483c9766a2b7daa5aa2a1050
3
+ metadata.gz: f7b2c000c852222f35914766b001264de3988fc1d4c2baa7b28504c885dad43a
4
+ data.tar.gz: d791271be3eb3118dfde048a732a672f5c5a65b80975ce7ea9f061504ca7b594
5
5
  SHA512:
6
- metadata.gz: f0d684f51de9dec607f6ce7e53fc95451f56bca9025e278d77e466c0030dfd7544be756260037cd99a80bd5969e941b4e0ec1c19c174cb9d4a841ddd25674ea0
7
- data.tar.gz: 2c6edaf85dc0084a817e619c28fc5147d346178a7ab9d9bb359774a3cefc4b6180fabeb5e4eb41f513f07a81379c74270374f5aab3737aac0b488528be12aca9
6
+ metadata.gz: 162584ae4fed3dacba0ee826fd707243d4150f1cfbabf00a40d1de0dd1433ac52e38157a9d553fef2d192ff31e7c8203b89d77cbfe8ea1bd709a479e4082d51c
7
+ data.tar.gz: 328caadb18a48ae8f103b79e91cf12b365139d5854e3f4e1a28bd27436de8bf04f5270e51a6aeddc9c4c19df1c55c97251e3bc2f20e5f5fdc8f7f24798502463
@@ -80,4 +80,22 @@ class UtilityCommands < Thor
80
80
  end
81
81
 
82
82
  map '-pl' => 'platform'
83
+
84
+ desc 'download_builds [build_type]', 'It downloads the example builds for appium projects'
85
+ def download_builds(build_type)
86
+ if %w[android, ios, both].include?(build_type)
87
+ raise 'Please select one of the following build types: android, ios, both'
88
+ end
89
+
90
+ Utilities.new.download_builds build_type
91
+ end
92
+
93
+ map '-d' => 'download_builds'
94
+
95
+ desc 'version', 'It shows the version of Ruby Raider you are currently using'
96
+ def version
97
+ Utilities.new.version
98
+ end
99
+
100
+ map '-v' => 'version'
83
101
  end
@@ -27,12 +27,14 @@ class AutomationGenerator < Generator
27
27
 
28
28
  def generate_header_component
29
29
  return unless (@_initializer.first & %w[android ios cross_platform]).empty?
30
+ return if @_initializer.first.last
30
31
 
31
32
  template('automation/component.tt', "#{name}/page_objects/components/header_component.rb")
32
33
  end
33
34
 
34
35
  def generate_abstract_component
35
36
  return unless (@_initializer.first & %w[android ios cross_platform]).empty?
37
+ return if @_initializer.first.last
36
38
 
37
39
  template('automation/abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
38
40
  end
@@ -42,4 +44,16 @@ class AutomationGenerator < Generator
42
44
 
43
45
  template('automation/appium_caps.tt', "#{name}/config/capabilities.yml")
44
46
  end
47
+
48
+ def generate_app_page
49
+ return unless @_initializer.first.last
50
+
51
+ template('automation/app_page.tt', "#{name}/page_objects/pages/app_page.rb")
52
+ end
53
+
54
+ def generate_visual_options
55
+ return unless @_initializer.first.last
56
+
57
+ template('automation/visual_options.tt', "#{name}/config/options.yml")
58
+ end
45
59
  end
@@ -22,10 +22,10 @@ class CommonGenerator < Generator
22
22
  end
23
23
 
24
24
  def create_allure_folder
25
- empty_directory "#{name}/allure-results"
25
+ empty_directory "#{name}/allure-results" unless @_initializer.first.last
26
26
  end
27
27
 
28
28
  def create_screenshots_folder
29
- empty_directory "#{name}/allure-results/screenshots"
29
+ empty_directory "#{name}/allure-results/screenshots" unless @_initializer.first.last
30
30
  end
31
31
  end
@@ -8,6 +8,7 @@ class Generator < Thor::Group
8
8
  argument :automation
9
9
  argument :framework
10
10
  argument :name
11
+ argument :visual_automation, optional: true
11
12
 
12
13
  def self.source_root
13
14
  "#{File.dirname(__FILE__)}/templates"
@@ -8,6 +8,8 @@ class HelpersGenerator < Generator
8
8
  end
9
9
 
10
10
  def generate_allure_helper
11
+ return if @_initializer.first.last
12
+
11
13
  template('helpers/allure_helper.tt', "#{name}/helpers/allure_helper.rb")
12
14
  end
13
15
 
@@ -16,6 +18,8 @@ class HelpersGenerator < Generator
16
18
  end
17
19
 
18
20
  def generate_spec_helper
21
+ return if @_initializer.first.last
22
+
19
23
  template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb") if @_initializer.first.include?('rspec')
20
24
  end
21
25
 
@@ -31,9 +35,21 @@ class HelpersGenerator < Generator
31
35
  template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
32
36
  end
33
37
 
34
- def generate_pdp_page
38
+ def generate_appium_helper
35
39
  return unless @_initializer.first.include?('cross_platform')
36
40
 
37
41
  template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
38
42
  end
43
+
44
+ def generate_visual_helper
45
+ return unless @_initializer.first.last
46
+
47
+ template('helpers/visual_helper.tt', "#{name}/helpers/visual_helper.rb")
48
+ end
49
+
50
+ def generate_visual_spec_helper
51
+ return unless @_initializer.first.last
52
+
53
+ template('helpers/visual_spec_helper.tt', "#{name}/helpers/spec_helper.rb")
54
+ end
39
55
  end
@@ -25,14 +25,22 @@ class MenuGenerator
25
25
  end
26
26
  end
27
27
 
28
+ def choose_visual_automation
29
+ prompt.select('Do you want to add visual automation with applitools?') do |menu|
30
+ menu.choice :Yes, -> { true }
31
+ menu.choice :No, -> { false }
32
+ menu.choice :Quit, -> { exit }
33
+ end
34
+ end
35
+
28
36
  def choose_test_framework(automation)
29
37
  return choose_mobile_platform if automation == 'appium'
30
38
 
31
39
  select_test_framework(automation)
32
40
  end
33
41
 
34
- def set_up_framework(automation, framework)
35
- generate_framework(automation, framework)
42
+ def set_up_framework(automation, framework, visual_automation)
43
+ generate_framework(automation, framework, visual_automation)
36
44
  system "cd #{name} && gem install bundler && bundle install"
37
45
  end
38
46
 
@@ -45,9 +53,9 @@ class MenuGenerator
45
53
  end
46
54
  end
47
55
 
48
- def generate_framework(automation, framework)
56
+ def generate_framework(automation, framework, visual_automation)
49
57
  add_generator framework.capitalize
50
- generators.each { |generator| invoke_generator(automation, framework, generator) }
58
+ generators.each { |generator| invoke_generator(automation, framework, generator, visual_automation) }
51
59
  end
52
60
 
53
61
  protected
@@ -59,7 +67,11 @@ class MenuGenerator
59
67
  private
60
68
 
61
69
  def framework_choice(framework, automation_type)
62
- set_up_framework(automation_type, framework.downcase)
70
+ visual_automation = if automation_type == 'selenium' && framework == 'Rspec'
71
+ choose_visual_automation
72
+ end
73
+
74
+ set_up_framework(automation_type, framework.downcase, visual_automation)
63
75
  prompt.say("You have chosen to use #{framework} with #{automation_type}")
64
76
  end
65
77
 
@@ -75,7 +87,7 @@ class MenuGenerator
75
87
  end
76
88
  end
77
89
 
78
- def invoke_generator(automation, framework, generator)
79
- Object.const_get("#{generator}Generator").new([automation, framework, name]).invoke_all
90
+ def invoke_generator(automation, framework, generator, visual_automation)
91
+ Object.const_get("#{generator}Generator").new([automation, framework, name, visual_automation]).invoke_all
80
92
  end
81
93
  end
@@ -7,4 +7,8 @@ class AbstractPage
7
7
  <%= ERB.new(File.read(File.expand_path('./partials/initialize_selector.tt', __dir__))).result(binding) -%>
8
8
  <%= ERB.new(File.read(File.expand_path('./partials/visit_method.tt', __dir__))).result(binding) -%>
9
9
  <%= ERB.new(File.read(File.expand_path('./partials/url_methods.tt', __dir__))).result(binding) -%>
10
+
11
+ def to_s
12
+ self.class.to_s.sub('Page', ' Page')
13
+ end
10
14
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../abstract/abstract_page'
4
+
5
+ class AppPage < AbstractPage
6
+ using Raider::SeleniumHelper
7
+
8
+ def url(_page)
9
+ 'app.html#'
10
+ end
11
+ end
@@ -1,6 +1,7 @@
1
- <% case automation
2
- when 'selenium' -%>
1
+ <% if automation == 'selenium' && visual_automation == true %>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/visual_login.tt', __dir__))).result(binding) %>
3
+ <% elsif automation == 'selenium' %>
3
4
  <%= ERB.new(File.read(File.expand_path('./partials/selenium_login.tt', __dir__))).result(binding) %>
4
- <% when 'watir' -%>
5
+ <% elsif automation == 'watir' %>
5
6
  <%= ERB.new(File.read(File.expand_path('./partials/watir_login.tt', __dir__))).result(binding) %>
6
- <% end -%>
7
+ <% end %>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../abstract/abstract_page'
4
+
5
+ class LoginPage < AbstractPage
6
+ using Raider::SeleniumHelper
7
+
8
+ def url(_page)
9
+ 'index.html'
10
+ end
11
+
12
+ # Actions
13
+
14
+ def login
15
+ login_button.click_when_present
16
+ end
17
+
18
+ private
19
+
20
+ # Elements
21
+
22
+ def login_button
23
+ driver.find_element(:id, 'log-in')
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ :batch_name: test_batch
2
+ :app_name: test_app
3
+ :test_name: app_test
4
+
5
+ :viewport_size:
6
+ :height: 800
7
+ :width: 600
8
+
9
+ :browsers:
10
+ - :name: chrome
11
+ :height: 800
12
+ :width: 600
13
+
14
+ :devices:
15
+ - :name: IPhoneX
16
+ :orientation: PORTRAIT
@@ -1,13 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activesupport'
4
+ <% unless visual_automation -%>
4
5
  gem 'allure-rspec'
5
6
  gem 'allure-ruby-commons'
7
+ <% end -%>
6
8
  <% if framework == 'cucumber' -%>
7
9
  gem 'allure-cucumber'
8
10
  <% end -%>
11
+ <% if visual_automation -%>
12
+ gem 'eyes_selenium'
13
+ <% end -%>
14
+ <% unless visual_automation -%>
9
15
  gem 'parallel_split_test'
10
16
  gem 'parallel_tests'
17
+ <% end -%>
11
18
  gem 'rake'
12
19
  gem '<%= framework %>'
13
20
  <% if framework == 'cucumber' -%>
@@ -1,2 +1,6 @@
1
1
  browser: :chrome
2
- url: 'https://automationteststore.com/'
2
+ <% if visual_automation == true %>
3
+ url: 'https://demo.applitools.com/'
4
+ <% else %>
5
+ url: 'https://automationteststore.com/'
6
+ <% end %>
@@ -10,8 +10,13 @@ module Raider
10
10
  <% else -%>
11
11
  require_relative 'driver_helper'
12
12
  <% end -%>
13
+ <% unless visual_automation -%>
13
14
  require_relative 'allure_helper'
15
+ <% end -%>
14
16
  <% if automation == 'cross_platform' -%>
15
17
  require_relative 'appium_helper'
16
18
  <% end -%>
19
+ <% if visual_automation -%>
20
+ require_relative 'visual_helper'
21
+ <% end -%>
17
22
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eyes_selenium'
4
+ require 'yaml'
5
+
6
+ module Raider
7
+ module VisualHelper
8
+ attr_reader :eyes
9
+
10
+ SELENIUM = Applitools::Selenium
11
+ VISUAL_GRID = SELENIUM::VisualGridRunner
12
+ EYES = SELENIUM::Eyes
13
+ TARGET = SELENIUM::Target
14
+ BATCHINFO = Applitools::BatchInfo
15
+ REGTANGLE_SIZE = Applitools::RectangleSize
16
+
17
+ def create_grid_runner(concurrency = 1)
18
+ VISUAL_GRID.new(concurrency)
19
+ end
20
+
21
+ def create_eyes(grid_runner)
22
+ EYES.new(runner: grid_runner)
23
+ end
24
+
25
+ def check_page(page)
26
+ page = format_page(page)
27
+ @eyes.check(page, TARGET.window.fully)
28
+ end
29
+
30
+ def configure_eyes(eyes, options = nil)
31
+ options ||= YAML.load_file('config/options.yml')
32
+
33
+ eyes.configure do |conf|
34
+ # You can get your api key from the Applitools dashboard
35
+ general_config(options, conf)
36
+ add_browsers(options[:browsers], conf)
37
+ add_devices(options[:devices], conf)
38
+ end
39
+ end
40
+
41
+ def format_page(page)
42
+ page.instance_of?(String) ? page : page.to_s
43
+ end
44
+
45
+ def add_browsers(browsers, conf)
46
+ browsers.each do |browser|
47
+ conf.add_browser(browser[:height], browser[:width], "BrowserType::#{browser[:name].upcase}".constantize)
48
+ end
49
+ end
50
+
51
+ def add_devices(devices, conf)
52
+ devices.each do |device|
53
+ conf.add_device_emulation("Devices::#{device[:name]}".constantize,
54
+ "Orientation::#{device[:orientation]}".constantize)
55
+ end
56
+ end
57
+
58
+ def general_config(options, conf)
59
+ conf.api_key = ENV['APPLITOOLS_API_KEY']
60
+ conf.batch = BATCHINFO.new(options[:batch_name])
61
+ conf.app_name = options[:app_name]
62
+ conf.test_name = options[:test_name]
63
+ conf.viewport_size = REGTANGLE_SIZE.new(options[:viewport_size][:height], options[:viewport_size][:width])
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require 'eyes_selenium'
5
+ require_relative 'driver_helper'
6
+ require_relative 'visual_helper'
7
+
8
+ module Raider
9
+ module SpecHelper
10
+ RSpec.configure do |config|
11
+ config.include(DriverHelper)
12
+ config.include(VisualHelper)
13
+ config.before(:each) do
14
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
15
+ @grid_runner = create_grid_runner
16
+ @eyes = create_eyes(@grid_runner)
17
+ configure_eyes @eyes
18
+ @driver = @eyes.open(driver: new_driver)
19
+ end
20
+
21
+ config.after(:each) do
22
+ @eyes.close
23
+ @driver.quit
24
+ @eyes.abort_async
25
+ results = @grid_runner.get_all_test_results
26
+ puts results
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,26 @@
1
- <% if %w[selenium watir].include? automation -%>
1
+ <% if automation == 'selenium' && visual_automation == true %>
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'base_spec'
5
+ require_relative '../page_objects/pages/login_page'
6
+ require_relative '../page_objects/pages/app_page'
7
+
8
+ describe 'Login Page' do
9
+ let(:app_page) { AppPage.new(@driver) }
10
+ let(:login_page) { LoginPage.new(@driver) }
11
+
12
+ before(:example) do
13
+ login_page.visit
14
+ end
15
+
16
+ it 'looks as expected' do
17
+ check_page login_page
18
+ login_page.login
19
+ check_page app_page
20
+ end
21
+ end
22
+
23
+ <% elsif %w[selenium watir].include? automation -%>
2
24
  require_relative 'base_spec'
3
25
  require_relative '../page_objects/pages/login_page'
4
26
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+ require 'open-uri'
4
5
 
5
6
  class Utilities
6
7
  def initialize
@@ -66,4 +67,38 @@ class Utilities
66
67
  def overwrite_yaml
67
68
  File.open(@path, 'w') { |file| YAML.dump(@config, file) }
68
69
  end
70
+
71
+ def version
72
+ spec_version = Gem::Specification.load('ruby_raider.gemspec').version
73
+ puts "The Ruby Raider version is #{spec_version}, Happy testing!"
74
+ end
75
+
76
+ def download_builds(build_type)
77
+ case build_type
78
+ when 'android'
79
+ download_android_build
80
+ when 'ios'
81
+ download_ios_build
82
+ else
83
+ download_android_build
84
+ download_ios_build
85
+ end
86
+ end
87
+
88
+ private
89
+
90
+ def download_android_build
91
+ download_build('Android-MyDemoAppRN.1.3.0.build-244.apk',
92
+ 'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/Android-MyDemoAppRN.1.3.0.build-244.apk')
93
+ end
94
+
95
+ def download_ios_build
96
+ download_build('iOS-Simulator-MyRNDemoApp.1.3.0-162.zip',
97
+ 'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/iOS-Simulator-MyRNDemoApp.1.3.0-162.zip')
98
+ end
99
+ def download_build(name, url)
100
+ open(name, 'wb') do |file|
101
+ file << open(url).read
102
+ end
103
+ end
69
104
  end
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.4'
5
+ s.version = '0.4.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']
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,7 @@ RSpec.configure do |config|
11
11
  config.before(:all) do
12
12
  FRAMEWORKS.each do |framework|
13
13
  AUTOMATION_TYPES.each do |automation|
14
- MenuGenerator.new("#{framework}_#{automation}").generate_framework(automation, framework)
14
+ MenuGenerator.new("#{framework}_#{automation}").generate_framework(automation, framework, false)
15
15
  end
16
16
  end
17
17
  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.4.4
4
+ version: 0.4.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-11-27 00:00:00.000000000 Z
11
+ date: 2022-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -155,6 +155,7 @@ 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/app_page.tt
158
159
  - lib/generators/templates/automation/appium_caps.tt
159
160
  - lib/generators/templates/automation/component.tt
160
161
  - lib/generators/templates/automation/home_page.tt
@@ -170,8 +171,10 @@ files:
170
171
  - lib/generators/templates/automation/partials/selenium_login.tt
171
172
  - lib/generators/templates/automation/partials/url_methods.tt
172
173
  - lib/generators/templates/automation/partials/visit_method.tt
174
+ - lib/generators/templates/automation/partials/visual_login.tt
173
175
  - lib/generators/templates/automation/partials/watir_login.tt
174
176
  - lib/generators/templates/automation/pdp_page.tt
177
+ - lib/generators/templates/automation/visual_options.tt
175
178
  - lib/generators/templates/common/config.tt
176
179
  - lib/generators/templates/common/gemfile.tt
177
180
  - lib/generators/templates/common/partials/automation_gems.tt
@@ -204,6 +207,8 @@ files:
204
207
  - lib/generators/templates/helpers/raider_helper.tt
205
208
  - lib/generators/templates/helpers/selenium_helper.tt
206
209
  - lib/generators/templates/helpers/spec_helper.tt
210
+ - lib/generators/templates/helpers/visual_helper.tt
211
+ - lib/generators/templates/helpers/visual_spec_helper.tt
207
212
  - lib/generators/templates/rspec/base_spec.tt
208
213
  - lib/generators/templates/rspec/spec.tt
209
214
  - lib/ruby_raider.rb
@@ -240,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
245
  - !ruby/object:Gem::Version
241
246
  version: '0'
242
247
  requirements: []
243
- rubygems_version: 3.3.7
248
+ rubygems_version: 3.3.3
244
249
  signing_key:
245
250
  specification_version: 4
246
251
  summary: A gem to make setup and start of UI automation projects easier