ruby_raider 0.7.5 → 0.7.7

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: 6187527f5296b729b6b97dfc897beb9d60809db17ab34fece7673c53a247be0f
4
- data.tar.gz: 2ac25c14abdc3c038390cf6ca0b1b1a36cab72366adef86c7cdf6d32984aadec
3
+ metadata.gz: e9cb054a366c6659aceb3252fbea25a07333f71224091584f2bd4c681b6c1203
4
+ data.tar.gz: d96e5fac73ec95f61b37f6b0de18905558b2060a02a7891fbb1052fcf1202122
5
5
  SHA512:
6
- metadata.gz: d999412e75b3f5b595d3615bc4664c0bc2c059385d8d397e970cce48565caa11712223654b6c28ae2892ba1ce03c3e72ddb305f272d9c61228053d93a7b92e8e
7
- data.tar.gz: 33f26594ee731b2dfce01861e13ee8423acca5411c583fe4d77784d54edea05f840cf95cdc85b70dcc15407ce041e8e3062dd46d35b9617a42c18e803dc5f276
6
+ metadata.gz: 17535a8af0e11cae31a6e2ff1e3edcafc252eb96fff79163918cefd259cc7d22c15cda67888ea558a437abadf3ba7c0febb37f4c10d77838b5265f2e647f3764
7
+ data.tar.gz: 8600c2438a466de652cfa93e1eede49967ac3422261d0e712677468bed91969d7746684d196b611a0076d44501ccbbe2aa007a05d588d95af5c831ee9c5b0b1b
data/README.md CHANGED
@@ -56,6 +56,10 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
56
56
 
57
57
  * Generating a visual testing framework with Cucumber, Applitools and Selenium
58
58
 
59
+ * Generating a mobile testing framework with Rspec and Sparkling Watir for IOS
60
+
61
+ * Generating a mobile testing framework with Cucumber and Sparkling Watir for IOS
62
+
59
63
  ***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
60
64
  ***Remember to use the full path of the app that you download in the capabilities file***
61
65
 
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'lib/ruby_raider'
4
4
  require_relative 'lib/commands/scaffolding_commands'
5
+ require_relative 'lib/utilities/logger'
5
6
 
6
7
  desc 'Creates a new test project'
7
8
  task :new, [:name] do |_t, args|
@@ -27,3 +28,8 @@ desc 'Download mobile builds'
27
28
  task :builds, [:type] do |_t, args|
28
29
  ScaffoldingCommands.new.invoke(:download_builds, nil, %W[#{args.type}])
29
30
  end
31
+
32
+ desc 'Logs a warning'
33
+ task :log, [:message] do |_t, args|
34
+ RubyRaider::Logger.warn(args.message)
35
+ end
@@ -1,7 +1,19 @@
1
- <%- if automation == 'cross_platform' -%>
2
- require_relative '../../helpers/appium_helper'
3
- <% end -%>
1
+ <%- if automation == 'sparkling_ios' -%>
2
+ require 'sparkling_watir/element'
3
+
4
+ class AbstractPage
5
+
6
+ attr_reader :app
7
+
8
+ def initialize(app)
9
+ @app = app
10
+ end
4
11
 
12
+ def to_s
13
+ self.class.to_s.sub('Page', ' Page')
14
+ end
15
+ end
16
+ <%- else -%>
5
17
  class AbstractPage
6
18
  <% if automation == 'cross_platform' -%>
7
19
  include AppiumHelper
@@ -14,3 +26,4 @@ class AbstractPage
14
26
  self.class.to_s.sub('Page', ' Page')
15
27
  end
16
28
  end
29
+ <%- end -%>
@@ -1,4 +1,4 @@
1
- <% if automation == 'ios' %>
1
+ <% if automation.include?('ios') %>
2
2
  <%= ERB.new(File.read(File.expand_path('./partials/ios_caps.tt', __dir__))).result(binding) -%>
3
3
  <% elsif automation == 'android' %>
4
4
  <%= ERB.new(File.read(File.expand_path('./partials/android_caps.tt', __dir__))).result(binding) -%>
@@ -1,7 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../abstract/abstract_page'
4
+ <%- if automation == 'sparkling_ios' -%>
5
+ class HomePage < AbstractPage
6
+
7
+ # Actions
4
8
 
9
+ def go_to_backpack_pdp
10
+ app.tap on: backpack_image.wait_until(&:present?)
11
+ end
12
+
13
+ private
14
+
15
+ # Elements
16
+
17
+ def backpack_image
18
+ app.element(predicate: 'label == "Sauce Labs Backpack"')
19
+ end
20
+ end
21
+ <%- else -%>
5
22
  class HomePage < AbstractPage
6
23
 
7
24
  # Actions
@@ -18,3 +35,4 @@ class HomePage < AbstractPage
18
35
  <%= ERB.new(File.read(File.expand_path('./partials/home_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
19
36
  end
20
37
  end
38
+ <%- end -%>
@@ -1,4 +1,22 @@
1
1
  require_relative '../abstract/abstract_page'
2
+ <%- if automation == 'sparkling_ios' -%>
3
+ class PdpPage < AbstractPage
4
+
5
+ # Actions
6
+
7
+ def add_to_cart_text
8
+ add_to_cart_button.wait_until(&:present?).text
9
+ end
10
+
11
+ private
12
+
13
+ # Elements
14
+
15
+ def add_to_cart_button
16
+ app.element(accessibility_id: 'Add To Cart button')
17
+ end
18
+ end
19
+ <%- else -%>
2
20
 
3
21
  class PdpPage < AbstractPage
4
22
 
@@ -16,3 +34,4 @@ class PdpPage < AbstractPage
16
34
  <%= ERB.new(File.read(File.expand_path('./partials/pdp_page_selector.tt', __dir__)), trim_mode: '-').result(binding) %>
17
35
  end
18
36
  end
37
+ <%- end -%>
@@ -1,3 +1,19 @@
1
+ <%- if automation == 'sparkling_ios' -%>
2
+ require_relative '../../helpers/driver_helper'
3
+
4
+ include DriverHelper
5
+
6
+ Before do
7
+ AllureHelper.configure
8
+ app
9
+ end
10
+
11
+ After do |scenario|
12
+ app.screenshot.save("allure-results/screenshots/#{scenario.name}.png")
13
+ AllureHelper.add_screenshot(scenario.name)
14
+ app.close
15
+ end
16
+ <%- else -%>
1
17
  require_relative '../../helpers/driver_helper'
2
18
 
3
19
  include DriverHelper
@@ -11,4 +27,5 @@ After do |scenario|
11
27
  driver.screenshot("allure-results/screenshots/#{scenario.name}.png")
12
28
  AllureHelper.add_screenshot(scenario.name)
13
29
  driver.quit_driver
14
- end
30
+ end
31
+ <%- end -%>
@@ -1,3 +1,22 @@
1
+ <%- if automation == 'sparkling_ios' -%>
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../../page_objects/pages/home_page'
5
+ require_relative '../../page_objects/pages/pdp_page'
6
+
7
+ Given("I'm an anonymous user on the home page") do
8
+ @home_page = HomePage.new(app)
9
+ end
10
+
11
+ When('I select one of the products') do
12
+ @home_page.go_to_backpack_pdp
13
+ end
14
+
15
+ When("I'm redirected to the product details page") do
16
+ pdp_page = PdpPage.new(app)
17
+ expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
18
+ end
19
+ <%- else -%>
1
20
  # frozen_string_literal: true
2
21
 
3
22
  require_relative '../../page_objects/pages/home_page'
@@ -15,3 +34,4 @@ When("I'm redirected to the product details page") do
15
34
  pdp_page = PdpPage.new(driver)
16
35
  expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
17
36
  end
37
+ <%- end -%>
@@ -29,11 +29,11 @@ class Generator < Thor::Group
29
29
  end
30
30
 
31
31
  def mobile?
32
- (args & %w[android ios cross_platform]).count.positive?
32
+ (args & %w[android ios cross_platform sparkling_ios]).count.positive?
33
33
  end
34
34
 
35
35
  def single_platform?
36
- (args & %w[android ios]).count.positive?
36
+ (args & %w[android ios sparkling_ios]).count.positive?
37
37
  end
38
38
 
39
39
  def rspec?
@@ -17,10 +17,7 @@ class MenuGenerator
17
17
 
18
18
  def generate_choice_menu
19
19
  prompt.select('Please select your automation framework') do |menu|
20
- menu.choice :Appium, -> { choose_test_framework('appium') }
21
- menu.choice :Selenium, -> { choose_test_framework('selenium') }
22
- menu.choice :Watir, -> { choose_test_framework('watir') }
23
- menu.choice :Quit, -> { exit }
20
+ select_automation_framework(menu)
24
21
  end
25
22
  end
26
23
 
@@ -30,6 +27,7 @@ class MenuGenerator
30
27
 
31
28
  def choose_test_framework(automation)
32
29
  return choose_mobile_platform if automation == 'appium'
30
+ return choose_sparkling_platform if automation == 'sparkling'
33
31
 
34
32
  select_test_framework(automation)
35
33
  end
@@ -45,6 +43,13 @@ class MenuGenerator
45
43
  system "cd #{name} && gem install bundler && bundle install"
46
44
  end
47
45
 
46
+ def choose_sparkling_platform
47
+ prompt.select('Please select your mobile platform') do |menu|
48
+ menu.choice :iOS, -> { choose_test_framework 'sparkling_ios' }
49
+ menu.choice :Quit, -> { exit }
50
+ end
51
+ end
52
+
48
53
  def choose_mobile_platform
49
54
  prompt.select('Please select your mobile platform') do |menu|
50
55
  menu.choice :iOS, -> { choose_test_framework 'ios' }
@@ -86,4 +91,12 @@ class MenuGenerator
86
91
  Quit: -> { exit }
87
92
  }
88
93
  end
94
+
95
+ def select_automation_framework(menu)
96
+ menu.choice :Appium, -> { choose_test_framework('appium') }
97
+ menu.choice :Selenium, -> { choose_test_framework('selenium') }
98
+ menu.choice 'Sparkling Watir', -> { choose_test_framework('sparkling') }
99
+ menu.choice :Watir, -> { choose_test_framework('watir') }
100
+ menu.choice :Quit, -> { exit }
101
+ end
89
102
  end
@@ -42,6 +42,23 @@ describe 'Login' do
42
42
  end
43
43
  end
44
44
  end
45
+ <%- elsif automation == 'sparkling_ios' -%>
46
+ require_relative '../helpers/spec_helper'
47
+ require_relative '../page_objects/pages/home_page'
48
+ require_relative '../page_objects/pages/pdp_page'
49
+
50
+ class PdpSpec
51
+ describe 'PDP page' do
52
+
53
+ let(:home_page) { HomePage.new(app) }
54
+ let(:pdp_page) { PdpPage.new(app) }
55
+
56
+ it 'shows add to cart button' do
57
+ home_page.go_to_backpack_pdp
58
+ expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
59
+ end
60
+ end
61
+ end
45
62
  <%- else -%>
46
63
  require_relative '../helpers/spec_helper'
47
64
  require_relative '../page_objects/pages/home_page'
@@ -30,3 +30,6 @@ gem 'ruby_raider', '~> 0.7.0'
30
30
  <% if %w[selenium watir].include? automation -%>
31
31
  gem 'webdrivers'
32
32
  <% end -%>
33
+ <% if automation == 'sparkling_ios' -%>
34
+ gem 'sparkling_watir'
35
+ <% end -%>
@@ -52,6 +52,10 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
52
52
 
53
53
  * Generating a visual testing framework with Cucumber, Applitools and Selenium
54
54
 
55
+ * Generating a mobile testing framework with Rspec and Sparkling Watir for IOS
56
+
57
+ * Generating a mobile testing framework with Cucumber and Sparkling Watir for IOS
58
+
55
59
  ***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
56
60
  ***Remember to use the full path of the app that you download in the capabilities file***
57
61
 
@@ -1,3 +1,25 @@
1
+ <%- if automation == 'sparkling_ios' -%>
2
+ # frozen_string_literal: true
3
+ require 'yaml'
4
+ require 'sparkling_watir'
5
+
6
+ module DriverHelper
7
+ def app
8
+ @app ||= create_app
9
+ end
10
+
11
+ private
12
+
13
+ def create_app
14
+ @app = SparklingWatir::App.new(caps: caps)
15
+ end
16
+
17
+ # :reek:UtilityFunction
18
+ def caps
19
+ YAML.load_file('config/capabilities.yml')
20
+ end
21
+ end
22
+ <%- else -%>
1
23
  # frozen_string_literal: true
2
24
  require 'yaml'
3
25
  <% if automation == 'selenium' -%>
@@ -29,3 +51,4 @@ module DriverHelper
29
51
  end
30
52
  <%- end -%>
31
53
  end
54
+ <%- end -%>
@@ -1,3 +1,30 @@
1
+ <%- if automation == 'sparkling_ios' -%>
2
+ # frozen_string_literal: true
3
+
4
+ require 'rspec'
5
+ require_relative 'allure_helper'
6
+ require_relative 'driver_helper'
7
+ require 'sparkling_watir'
8
+
9
+ module SpecHelper
10
+
11
+ AllureHelper.configure
12
+ RSpec.configure do |config|
13
+ config.formatter = AllureHelper.formatter
14
+ config.include(DriverHelper)
15
+ config.before(:each) do
16
+ app
17
+ end
18
+
19
+ config.after(:each) do
20
+ example_name = self.class.descendant_filtered_examples.first.description
21
+ app.screenshot.save("allure-results/screenshots/#{example_name}.png")
22
+ AllureHelper.add_screenshot example_name
23
+ app.close
24
+ end
25
+ end
26
+ end
27
+ <%- else -%>
1
28
  # frozen_string_literal: true
2
29
 
3
30
  require 'rspec'
@@ -27,4 +54,5 @@ module SpecHelper
27
54
  <%= ERB.new(File.read(File.expand_path('./partials/quit_driver.tt', __dir__)), trim_mode: '-').result(binding).strip! %>
28
55
  end
29
56
  end
30
- end
57
+ end
58
+ <%- end -%>
data/lib/ruby_raider.rb CHANGED
@@ -19,7 +19,7 @@ module RubyRaider
19
19
  desc 'version', 'It shows the version of Ruby Raider you are currently using'
20
20
 
21
21
  def version
22
- puts 'The Ruby Raider version is 0.7.4, Happy testing!'
22
+ puts 'The Ruby Raider version is 0.7.7, Happy testing!'
23
23
  end
24
24
 
25
25
  map 'v' => 'version'
@@ -0,0 +1,26 @@
1
+ require 'forwardable'
2
+ require 'logger'
3
+
4
+ module RubyRaider
5
+ module Logger
6
+ #
7
+ # @example Use logger manually
8
+ # RubyRaider::Logger.debug('This is info message')
9
+ # RubyRaider::Logger.warn('This is warning message')
10
+ #
11
+ class << self
12
+ extend Forwardable
13
+ def_delegators :logger, :fatal, :error, :warn, :info, :debug, :level, :level=, :formatter, :formatter=
14
+
15
+ def logger
16
+ @logger ||= begin
17
+ logger = ::Logger.new($stdout)
18
+ logger.progname = 'ruby_raider'
19
+ logger.level = ::Logger::WARN
20
+ logger.formatter = proc { |_severity, _datetime, _progname, msg| "#{msg}\n" }
21
+ logger
22
+ end
23
+ end
24
+ end
25
+ end
26
+ 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.7.5'
5
+ s.version = '0.7.7'
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']
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency 'rubocop-performance', '~> 1.15.0'
22
22
  s.add_development_dependency 'rubocop-rspec', '~> 2.9.0'
23
23
 
24
- s.add_runtime_dependency 'faraday', '~> 1.2.0'
24
+ s.add_runtime_dependency 'faraday', '~> 2.7', '>= 2.7.10'
25
25
  s.add_runtime_dependency 'ruby-openai', '~> 3.5'
26
26
  s.add_runtime_dependency 'thor', '~> 1.2.1'
27
27
  s.add_runtime_dependency 'tty-prompt', '~> 0.23.1'
@@ -24,12 +24,6 @@ describe CommonGenerator do
24
24
  end
25
25
  end
26
26
 
27
- shared_examples 'creates a config file' do |name|
28
- it 'creates a config file' do
29
- expect(File).to exist("#{name}/config/config.yml")
30
- end
31
- end
32
-
33
27
  shared_examples "doesn't create a config file" do |name|
34
28
  it "doesn't create a config file" do
35
29
  expect(File).not_to exist("#{name}/config/config.yml")
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.7.5
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pequeno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-15 00:00:00.000000000 Z
11
+ date: 2023-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -114,14 +114,20 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2.0
117
+ version: '2.7'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 2.7.10
118
121
  type: :runtime
119
122
  prerelease: false
120
123
  version_requirements: !ruby/object:Gem::Requirement
121
124
  requirements:
122
125
  - - "~>"
123
126
  - !ruby/object:Gem::Version
124
- version: 1.2.0
127
+ version: '2.7'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 2.7.10
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: ruby-openai
127
133
  requirement: !ruby/object:Gem::Requirement
@@ -265,6 +271,7 @@ files:
265
271
  - lib/scaffolding/templates/helper.tt
266
272
  - lib/scaffolding/templates/page_object.tt
267
273
  - lib/scaffolding/templates/spec.tt
274
+ - lib/utilities/logger.rb
268
275
  - lib/utilities/utilities.rb
269
276
  - ruby_raider.gemspec
270
277
  - spec/automation_generator_spec.rb