ruby_raider 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0c6d3fae74a6d921b96f3aeb216fef51378824aa78a24cbb5f9bb8a2f7c22e
4
- data.tar.gz: 274ef6e35550c02473a6e6d6ffee85ca88f3a9279e379241da6b0177c7c1210e
3
+ metadata.gz: 47cababb68c29a1a13ad36bb58a37f67aa9b0aad02a329a1fe3215af3cfa1174
4
+ data.tar.gz: 44f078d705101b3e233a06b1b5e6f30b7ff730a9923647c681faf7689c676d69
5
5
  SHA512:
6
- metadata.gz: 0bc058b73aff5b99a92a06220c5d6f84e3314fca9eb99cb8a02f983308f755de245c751133fc9f9357bad8836c7cf575e0dddfd9ee83c2231e2ed5934ad71dc2
7
- data.tar.gz: 5d45ba62bde3a8e3f317ec0392d3b7448b2b2ae56896f6d143916dcee9b4b37847b7fcc3e5e5dee2f1dcd8e1a735812744bc7c18943c08c4a130bffe0f653686
6
+ metadata.gz: a638b7050b95dfde750279a26722abb645f56f175f4729e02af8f6acad0f2b3448617aaddaf87dbc7fd14b417dca56048d52dfe2e936f26f52b94f2320818f02
7
+ data.tar.gz: 0e28acc526f8d775704e8642b3a7ac7a9da35d1d399acf7949b3c4bb6bd9a39694ce5f5e460ba5050d94923597c507f55561c64b94533da7ef58118385e18eb0
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  ruby_raider-*.gem
2
- .idea/
2
+ .idea/
3
+ ruby_raider.iml
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/README.md CHANGED
@@ -3,13 +3,18 @@ This is a gem to make setup and start of UI automation projects easier
3
3
 
4
4
  Just do:
5
5
 
6
- gem install ruby_raider
6
+ **gem install ruby_raider**
7
7
 
8
- then do raider [name_of_project]
8
+ then do:
9
+
10
+ **raider [name_of_project]**
9
11
 
10
12
  and you will have a new project in the folder you are in
11
13
 
12
- Currently we only support Watir with Rspec.
14
+ Currently we only support:
15
+
16
+ * Gerating a Selenium with Rspec framework
17
+ * Gerating a Watir with Rspec framework
13
18
 
14
19
  We have only tested this in mac and linux, so it works in both platforms.
15
20
 
data/bin/raider CHANGED
File without changes
@@ -1,43 +1,23 @@
1
1
  require_relative 'file_generator'
2
2
 
3
3
  module RubyRaider
4
- class WatirFileGenerator < FileGenerator
5
- def self.generate_watir_files(name)
6
- generate_file('abstract_page.rb', "#{name}/page_objects/abstract", abstract_page)
7
- generate_file('abstract_component.rb', "#{name}/page_objects/abstract", abstract_component)
8
- generate_file('login_page.rb', "#{name}/page_objects/pages", example_page)
4
+ class AutomationFileGenerator < FileGenerator
5
+ def self.generate_automation_files(name, automation, framework)
6
+ generate_file('abstract_page.rb', "#{name}/page_objects/abstract", abstract_page(automation, framework))
7
+ generate_file('abstract_component.rb', "#{name}/page_objects/abstract", abstract_component(framework))
8
+ generate_file('login_page.rb', "#{name}/page_objects/pages", example_page(automation))
9
9
  generate_file('header_component.rb', "#{name}/page_objects/components", example_component)
10
- generate_file('Gemfile', name.to_s, gemfile_template)
11
10
  end
12
11
 
13
- def self.gemfile_template
14
- gemfile = ERB.new <<~EOF
15
- # frozen_string_literal: true
16
-
17
- source 'https://rubygems.org'
18
-
19
- gem 'activesupport'
20
- gem 'allure-rspec'
21
- gem 'allure-ruby-commons'
22
- gem 'parallel_split_test'
23
- gem 'parallel_tests'
24
- gem 'rake'
25
- gem 'rspec'
26
- gem 'selenium-webdriver'
27
- gem 'watir'
28
- gem 'webdrivers'
29
- EOF
30
- gemfile.result(binding)
31
- end
32
-
33
- def self.example_page
12
+ def self.example_page(automation)
13
+ element = automation == 'watir' ? 'browser.element' : 'driver.find_element'
34
14
  page_file = ERB.new <<~EOF
35
15
  require_relative '../abstract/abstract_page'
36
16
  require_relative '../components/header_component'
37
17
 
38
18
  class LoginPage < AbstractPage
39
19
 
40
- using Raider::WatirHelper
20
+ using #{automation == 'watir' ? 'Raider::WatirHelper' : 'Raider::SeleniumHelper'}
41
21
 
42
22
  def url(_page)
43
23
  'index.php?rt=account/login'
@@ -46,15 +26,15 @@ module RubyRaider
46
26
  # Actions
47
27
 
48
28
  def login(username, password)
49
- username_field.set username
50
- password_field.set password
29
+ username_field.send_keys username
30
+ password_field.send_keys password
51
31
  login_button.click_when_present
52
32
  end
53
33
 
54
34
  # Components
55
35
 
56
36
  def header
57
- HeaderComponent.new(browser.element(class: 'menu_text'))
37
+ HeaderComponent.new(#{element}(class: 'menu_text'))
58
38
  end
59
39
 
60
40
  private
@@ -62,37 +42,47 @@ module RubyRaider
62
42
  # Elements
63
43
 
64
44
  def username_field
65
- browser.text_field(id: 'loginFrm_loginname')
45
+ #{element}(id: 'loginFrm_loginname')
66
46
  end
67
47
 
68
48
  def password_field
69
- browser.text_field(id: 'loginFrm_password')
49
+ #{element}(id: 'loginFrm_password')
70
50
  end
71
51
 
72
52
  def login_button
73
- browser.button(visible_text: 'Login')
53
+ #{element}(xpath: "//button[@title='Login']")
74
54
  end
75
55
  end
76
56
  EOF
77
57
  page_file.result(binding)
78
58
  end
79
59
 
80
- def self.abstract_page
60
+ def self.abstract_page(automation, framework)
61
+ browser = "def browser
62
+ Raider::BrowserHelper.browser
63
+ end"
64
+ driver = "def driver
65
+ Raider::DriverHelper.driver
66
+ end"
67
+ visit = automation == 'watir' ? 'browser.goto full_url(page.first)' : 'driver.navigate.to full_url(page.first)'
68
+ raider = if framework == 'rspec'
69
+ "require_relative '../../helpers/raider'"
70
+ else
71
+ "require_relative '../../features/support/helpers/raider'"
72
+ end
81
73
  abstract_file = ERB.new <<~EOF
82
74
  require 'rspec'
83
- require_relative '../../helpers/raider'
75
+ #{raider}
84
76
 
85
77
  class AbstractPage
86
78
 
87
79
  include RSpec::Matchers
88
80
  extend Raider::PomHelper
89
81
 
90
- def browser
91
- Raider::BrowserHelper.browser
92
- end
82
+ #{automation == 'watir' ? browser : driver}
93
83
 
94
84
  def visit(*page)
95
- browser.goto full_url(page.first)
85
+ #{visit}
96
86
  end
97
87
 
98
88
  def full_url(*page)
@@ -107,7 +97,6 @@ module RubyRaider
107
97
  raise 'Url must be defined on child pages'
108
98
  end
109
99
  end
110
-
111
100
  EOF
112
101
  abstract_file.result(binding)
113
102
  end
@@ -126,15 +115,21 @@ module RubyRaider
126
115
  page_file.result(binding)
127
116
  end
128
117
 
129
- def self.abstract_component
118
+ def self.abstract_component(framework)
119
+ raider = if framework == 'rspec'
120
+ "require_relative '../../helpers/raider'"
121
+ else
122
+ "require_relative '../../features/support/helpers/raider'"
123
+ end
130
124
  abstract_file = ERB.new <<~EOF
131
- require_relative '../../helpers/raider'
125
+ #{raider}
126
+
127
+ class AbstractComponent
132
128
 
133
- class AbstractComponent
134
- def initialize(component)
135
- @component = component
136
- end
137
- end
129
+ def initialize(component)
130
+ @component = component
131
+ end
132
+ end
138
133
  EOF
139
134
  abstract_file.result(binding)
140
135
  end
@@ -2,10 +2,11 @@ require_relative 'file_generator'
2
2
 
3
3
  module RubyRaider
4
4
  class CommonFileGenerator < FileGenerator
5
- def self.generate_common_files(name)
5
+ def self.generate_common_files(name, framework)
6
6
  generate_file('config.yml', "#{name}/config", config_file)
7
7
  generate_file('Rakefile', name.to_s, rake_file)
8
8
  generate_file('Readme.md', name.to_s, readme_file)
9
+ generate_file('Gemfile', name.to_s, gemfile_template((framework)))
9
10
  end
10
11
 
11
12
  def self.readme_file
@@ -130,5 +131,32 @@ module RubyRaider
130
131
  EOF
131
132
  rake_file.result(binding)
132
133
  end
134
+
135
+ def self.gemfile_template(framework)
136
+ if framework == 'cucumber'
137
+ allure_cucumber = "gem 'allure-cucumber'"
138
+ rspec = "gem 'rspec'"
139
+ end
140
+
141
+ gemfile = ERB.new <<~EOF
142
+ # frozen_string_literal: true
143
+
144
+ source 'https://rubygems.org'
145
+
146
+ gem 'activesupport'
147
+ gem 'allure-rspec'
148
+ gem 'allure-ruby-commons'
149
+ #{allure_cucumber}
150
+ gem 'parallel_split_test'
151
+ gem 'parallel_tests'
152
+ gem 'rake'
153
+ gem '#{framework}'
154
+ #{rspec}
155
+ gem 'selenium-webdriver'
156
+ gem 'watir'
157
+ gem 'webdrivers'
158
+ EOF
159
+ gemfile.result(binding)
160
+ end
133
161
  end
134
162
  end
@@ -0,0 +1,81 @@
1
+ require_relative 'file_generator'
2
+
3
+ module RubyRaider
4
+ class CucumberFileGenerator < FileGenerator
5
+ def self.generate_cucumber_files(name, automation)
6
+ CommonFileGenerator.generate_common_files(name, 'cucumber')
7
+ HelpersFileGenerator.generate_helper_files(name, automation, 'cucumber')
8
+ generate_file('login.feature', "#{name}/features", example_feature)
9
+ generate_file('login_steps.rb', "#{name}/features/step_definitions", example_steps)
10
+ generate_file('env.rb', "#{name}/features/support", env(automation))
11
+ AutomationFileGenerator.generate_automation_files(name, automation, 'framework')
12
+ end
13
+
14
+ def self.example_feature
15
+ gemfile = ERB.new <<~EOF
16
+ Feature: Login Page
17
+
18
+ Scenario: A user can login
19
+ Given I'm a registered user on the login page
20
+ When I login with my credentials
21
+ Then I can see the main page
22
+
23
+ EOF
24
+ gemfile.result(binding)
25
+ end
26
+
27
+ def self.example_steps
28
+ gemfile = ERB.new <<~EOF
29
+ require_relative '../../page_objects/pages/login_page'
30
+
31
+ Given("I'm a registered user on the login page") do
32
+ LoginPage.visit
33
+ end
34
+
35
+ When('I login with my credentials') do
36
+ LoginPage.login('aguspe', '12341234')
37
+ end
38
+
39
+ When('I can see the main page') do
40
+ expect(LoginPage.header.customer_name).to eq 'Welcome back Agustin'
41
+ end
42
+ EOF
43
+ gemfile.result(binding)
44
+ end
45
+
46
+ def self.env(automation)
47
+ if automation == 'watir'
48
+ helper = 'helpers/browser_helper'
49
+ browser = 'Raider::BrowserHelper.new_browser'
50
+ get_browser = 'browser = Raider::BrowserHelper.new_browser'
51
+ screenshot = 'browser.screenshot.save("allure-results/screenshots/#{scenario.name}.png")'
52
+ quit = 'browser.quit'
53
+ else
54
+ helper = 'helpers/driver_helper'
55
+ browser = 'Raider::DriverHelper.new_driver'
56
+ get_browser = 'driver = Raider::DriverHelper.driver'
57
+ screenshot = 'driver.save_screenshot("allure-results/screenshots/#{scenario.name}.png")'
58
+ quit = 'driver.quit'
59
+ end
60
+
61
+ gemfile = ERB.new <<~EOF
62
+ require 'active_support/all'
63
+ require_relative 'helpers/allure_helper'
64
+ require_relative '#{helper}'
65
+
66
+ Before do
67
+ Raider::AllureHelper.configure
68
+ #{browser}
69
+ end
70
+
71
+ After do |scenario|
72
+ #{get_browser}
73
+ #{screenshot}
74
+ Raider::AllureHelper.add_screenshot(scenario.name)
75
+ #{quit}
76
+ end
77
+ EOF
78
+ gemfile.result(binding)
79
+ end
80
+ end
81
+ end
@@ -2,24 +2,25 @@ require_relative 'file_generator'
2
2
 
3
3
  module RubyRaider
4
4
  class HelpersFileGenerator < FileGenerator
5
- def self.generate_helper_files(name, automation)
6
- generate_file('raider.rb', "#{name}/helpers", generate_raider_helper((automation)))
7
- generate_file('allure_helper.rb', "#{name}/helpers", generate_allure_helper)
8
- generate_file('pom_helper.rb', "#{name}/helpers", generate_pom_helper)
9
- generate_file('spec_helper.rb', "#{name}/helpers", generate_spec_helper((automation)))
5
+ def self.generate_helper_files(name, automation, framework)
6
+ path = framework == 'rspec' ? "#{name}/helpers" : "#{name}/features/support/helpers"
7
+ generate_file('raider.rb', path, generate_raider_helper(automation, framework))
8
+ generate_file('allure_helper.rb', path, generate_allure_helper(framework))
9
+ generate_file('pom_helper.rb', path, generate_pom_helper)
10
+ generate_file('spec_helper.rb', path, generate_spec_helper((automation))) if framework == 'rspec'
10
11
  if automation == 'watir'
11
- generate_file('watir_helper.rb', "#{name}/helpers", generate_watir_helper)
12
- generate_file('browser_helper.rb', "#{name}/helpers", generate_browser_helper)
12
+ generate_file('watir_helper.rb', path, generate_watir_helper)
13
+ generate_file('browser_helper.rb', path, generate_browser_helper)
13
14
  else
14
- generate_file('selenium_helper.rb', "#{name}/helpers", generate_selenium_helper)
15
- generate_file('driver_helper.rb', "#{name}/helpers", generate_driver_helper)
15
+ generate_file('selenium_helper.rb', path, generate_selenium_helper)
16
+ generate_file('driver_helper.rb', path, generate_driver_helper)
16
17
  end
17
18
  end
18
19
 
19
- def self.generate_raider_helper(automation)
20
+ def self.generate_raider_helper(automation, framework)
20
21
  spec = ERB.new <<~EOF
21
22
  module Raider
22
- require_relative 'spec_helper'
23
+ #{"require_relative 'spec_helper'" if framework == 'rspec'}
23
24
  require_relative '#{automation}_helper'
24
25
  require_relative 'pom_helper'
25
26
  require_relative '#{automation == 'watir' ? 'browser_helper' : 'driver_helper'}'
@@ -30,34 +31,44 @@ module RubyRaider
30
31
  spec.result(binding)
31
32
  end
32
33
 
33
- def self.generate_allure_helper
34
+ def self.generate_allure_helper(framework)
35
+ if framework == 'cucumber'
36
+ gems = "require 'allure-cucumber'"
37
+ allure = 'AllureCucumber'
38
+ else
39
+ gems = "require 'allure-ruby-commons'
40
+ require 'allure-rspec'"
41
+ allure = 'AllureRspec'
42
+ end
34
43
  spec = ERB.new <<~EOF
35
- require 'allure-ruby-commons'
36
- require 'allure-rspec'
44
+ #{gems}
37
45
 
38
46
  module Raider
39
47
  module AllureHelper
40
48
  class << self
41
49
 
42
50
  def configure
43
- AllureRspec.configure do |config|
51
+ #{allure}.configure do |config|
44
52
  config.results_directory = 'allure-results'
45
53
  config.clean_results_directory = true
46
54
  end
47
55
  end
48
56
 
49
- def add_screenshot(name)
57
+ def add_screenshot(screenshot_name)
50
58
  Allure.add_attachment(
51
59
  name: name,
52
- source: File.open("allure-results/screenshots/#{name}.png"),
60
+ source: "File.open(allure-results/screenshots/\#{screenshot_name}.png)",
53
61
  type: Allure::ContentType::PNG,
54
62
  test_case: true
55
63
  )
56
64
  end
57
65
 
58
- def formatter
59
- AllureRspecFormatter
60
- end
66
+ #{
67
+ if framework == 'rspec'
68
+ 'def formatter
69
+ AllureRspecFormatter
70
+ end'
71
+ end }
61
72
  end
62
73
  end
63
74
  end
@@ -84,6 +95,7 @@ module RubyRaider
84
95
  end
85
96
  end
86
97
  end
98
+
87
99
  EOF
88
100
  spec.result(binding)
89
101
  end
@@ -171,7 +183,7 @@ module RubyRaider
171
183
  require 'selenium-webdriver'
172
184
  require_relative 'driver_helper'
173
185
 
174
- module ExampleDsl
186
+ module Raider
175
187
  module SeleniumHelper
176
188
  def click_when_present
177
189
  # This is an example of an implicit wait in selenium
@@ -225,8 +237,6 @@ module RubyRaider
225
237
  end
226
238
  end
227
239
  end
228
-
229
-
230
240
  EOF
231
241
  spec.result(binding)
232
242
  end
@@ -1,21 +1,16 @@
1
1
  require_relative 'common_file_generator'
2
2
  require_relative 'file_generator'
3
3
  require_relative 'helpers_file_generator'
4
- require_relative 'selenium_file_generator'
5
- require_relative 'watir_file_generator'
4
+ require_relative 'automation_file_generator'
6
5
 
7
6
  module RubyRaider
8
7
  class RspecFileGenerator < FileGenerator
9
8
  def self.generate_rspec_files(name, automation)
10
- CommonFileGenerator.generate_common_files(name)
11
- HelpersFileGenerator.generate_helper_files(name, automation)
9
+ CommonFileGenerator.generate_common_files(name, 'rspec')
10
+ HelpersFileGenerator.generate_helper_files(name, automation, 'rspec')
12
11
  generate_file('login_page_spec.rb', "#{name}/spec", generate_example_spec)
13
12
  generate_file('base_spec.rb', "#{name}/spec", generate_base_spec)
14
- if automation == 'watir'
15
- WatirFileGenerator.generate_watir_files(name)
16
- else
17
- SeleniumFileGenerator.generate_selenium_files(name)
18
- end
13
+ AutomationFileGenerator.generate_automation_files(name, automation, 'rspec')
19
14
  end
20
15
 
21
16
  def self.generate_example_spec
@@ -1,4 +1,5 @@
1
1
  require 'highline'
2
+ require_relative '../generators/projects/cucumber_project_generator'
2
3
  require_relative '../generators/projects/rspec_project_generator'
3
4
 
4
5
  module RubyRaider
@@ -20,16 +21,25 @@ module RubyRaider
20
21
  framework = ''
21
22
  cli.choose do |menu|
22
23
  menu.prompt = 'Please select your test framework'
23
- menu.choice(:Rspec) { framework = 'Rspec'; set_rspec_framework(automation, project_name)}
24
- menu.choice(:Cucumber) { framework = 'cucumber'; 'We are still working on supporting this' }
24
+ menu.choice(:Rspec) do
25
+ framework = 'rspec'
26
+ set_framework(automation, framework, project_name)
27
+ end
28
+ menu.choice(:Cucumber) do
29
+ framework = 'cucumber'
30
+ set_framework(automation, framework, project_name)
31
+ end
25
32
  menu.choice(:Quit, 'Exit program.') { exit }
26
33
  end
27
34
  cli.say("You have chosen to use #{framework} with #{automation}")
28
35
  end
29
36
 
30
- def self.set_rspec_framework(automation, project_name)
31
- RspecProjectGenerator.generate_rspec_project(project_name, automation: automation)
32
- ProjectGenerator.install_gems(project_name)
37
+ def self.set_framework(automation, framework, project_name)
38
+ if framework == 'rspec'
39
+ RspecProjectGenerator.generate_rspec_project(project_name, automation: automation)
40
+ else
41
+ CucumberProjectGenerator.generate_cucumber_project(project_name, automation: automation)
42
+ end
33
43
  end
34
44
  end
35
45
  end
@@ -1,14 +1,24 @@
1
+ require_relative '../files/cucumber_file_generator'
1
2
  require_relative 'project_generator'
2
3
 
3
4
  module RubyRaider
4
- class CucumberProjectGenerator
5
- def cucumber_folder_structure(name)
5
+ class CucumberProjectGenerator < ProjectGenerator
6
+ def self.generate_cucumber_project(name, automation: 'watir')
7
+ cucumber_folder_structure(name)
8
+ CucumberFileGenerator.generate_cucumber_files(name, automation)
9
+ ProjectGenerator.install_gems(name)
10
+ end
11
+
12
+ def self.cucumber_folder_structure(name)
6
13
  Dir.mkdir name.to_s
7
- Dir.mkdir "#{name}/features"
8
- folders = %w[steps_definitions support]
14
+ folders = %w[features config page_objects allure-results]
15
+ create_children_folders("#{name}", folders)
16
+ folders = %w[step_definitions support]
9
17
  create_children_folders("#{name}/features", folders)
10
18
  Dir.mkdir "#{name}/features/support/helpers"
11
- Dir.mkdir "#{name}/page_objects"
19
+ folders = %w[abstract pages components]
20
+ create_children_folders("#{name}/page_objects", folders)
21
+ Dir.mkdir "#{name}/allure-results/screenshots"
12
22
  end
13
23
  end
14
24
  end
@@ -5,7 +5,8 @@ module RubyRaider
5
5
  class RspecProjectGenerator < ProjectGenerator
6
6
  def self.generate_rspec_project(name, automation: 'watir')
7
7
  rspec_folder_structure(name)
8
- rspec_files(name, automation)
8
+ RspecFileGenerator.generate_rspec_files(name, automation)
9
+ ProjectGenerator.install_gems(name)
9
10
  end
10
11
 
11
12
  def self.rspec_folder_structure(name)
@@ -15,9 +16,5 @@ module RubyRaider
15
16
  pages = %w[pages components abstract]
16
17
  create_children_folders("#{name}/page_objects", pages)
17
18
  end
18
-
19
- def self.rspec_files(name, automation)
20
- RspecFileGenerator.generate_rspec_files(name, automation)
21
- end
22
19
  end
23
20
  end
data/lib/ruby_raider.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'generators/projects/rspec_project_generator'
5
5
 
6
6
  module RubyRaider
7
7
  extend self
8
- def generate_project(project_name)
9
- MenuGenerator.generate_choice_menu(project_name)
10
- end
8
+ def generate_project(project_name)
9
+ MenuGenerator.generate_choice_menu(project_name)
10
+ end
11
11
  end
data/ruby_raider.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ruby_raider'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.4'
4
4
  s.summary = 'A gem to make setup and start of UI automation projects easier'
5
5
  s.description = 'This gem contents everything you need to start doing web automation in one simple package'
6
6
  s.authors = ['Agustin Pequeno']
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files -z`.split("\x0")
13
13
  s.bindir = 'bin'
14
14
  s.executables << 'raider'
15
- s.add_development_dependency 'rspec'
15
+ s.add_development_dependency 'rake', '~> 13.0.6'
16
+ s.add_development_dependency 'rspec', '~> 3.11.0'
16
17
 
17
- s.add_runtime_dependency 'highline'
18
+ s.add_runtime_dependency 'highline', '~> 2.0.3'
18
19
  end
@@ -1,7 +1,7 @@
1
- require_relative '../lib/generators/files/watir_file_generator'
1
+ require_relative '../lib/generators/files/automation_file_generator'
2
2
  require_relative 'spec_helper'
3
3
 
4
- describe RubyRaider::WatirFileGenerator do
4
+ describe RubyRaider::AutomationFileGenerator do
5
5
  it 'creates a login page file' do
6
6
  expect(File.exist?("#{@project_name}/page_objects/pages/login_page.rb")).to be_truthy
7
7
  end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_raider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pequeno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-09 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 13.0.6
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 13.0.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ">="
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: 3.11.0
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: 3.11.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: highline
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 2.0.3
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: 2.0.3
41
55
  description: This gem contents everything you need to start doing web automation in
42
56
  one simple package
43
57
  email: agustin.pe94@gmail.com
@@ -47,29 +61,29 @@ extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
49
63
  - ".gitignore"
64
+ - Gemfile
50
65
  - README.md
51
66
  - Rakefile
52
67
  - bin/raider
68
+ - lib/generators/files/automation_file_generator.rb
53
69
  - lib/generators/files/common_file_generator.rb
70
+ - lib/generators/files/cucumber_file_generator.rb
54
71
  - lib/generators/files/file_generator.rb
55
72
  - lib/generators/files/helpers_file_generator.rb
56
73
  - lib/generators/files/rspec_file_generator.rb
57
- - lib/generators/files/selenium_file_generator.rb
58
- - lib/generators/files/watir_file_generator.rb
59
74
  - lib/generators/menu_generator.rb
60
75
  - lib/generators/projects/cucumber_project_generator.rb
61
76
  - lib/generators/projects/project_generator.rb
62
77
  - lib/generators/projects/rspec_project_generator.rb
63
78
  - lib/ruby_raider.rb
64
79
  - ruby_raider.gemspec
80
+ - spec/automation_file_generator_spec.rb
65
81
  - spec/common_file_generator_spec.rb
66
82
  - spec/helpers_file_generator_spec.rb
67
83
  - spec/menu_generator_spec.rb
68
84
  - spec/rspec_file_generator_spec.rb
69
85
  - spec/rspec_project_generator_spec.rb
70
- - spec/selenium_file_generator_spec.rb
71
86
  - spec/spec_helper.rb
72
- - spec/watir_file_generator_spec.rb
73
87
  homepage: http://github.com/aguspe/ruby_raider
74
88
  licenses:
75
89
  - MIT
@@ -1,159 +0,0 @@
1
- require_relative 'file_generator'
2
-
3
- module RubyRaider
4
- class SeleniumFileGenerator < FileGenerator
5
- def self.generate_selenium_files(name)
6
- generate_file('abstract_page.rb', "#{name}/page_objects/abstract", abstract_page)
7
- generate_file('abstract_page_object.rb', "#{name}/page_objects/abstract", abstract_page_object)
8
- generate_file('abstract_component.rb', "#{name}/page_objects/abstract", abstract_component)
9
- generate_file('login_page.rb', "#{name}/page_objects/pages", example_page)
10
- generate_file('header_component.rb', "#{name}/page_objects/components", example_component)
11
- generate_file('Gemfile', name.to_s, gemfile_template)
12
- end
13
-
14
- def self.gemfile_template
15
- gemfile = ERB.new <<~EOF
16
- # frozen_string_literal: true
17
-
18
- source 'https://rubygems.org'
19
-
20
- gem 'activesupport'
21
- gem 'allure-rspec'
22
- gem 'allure-ruby-commons'
23
- gem 'parallel_split_test'
24
- gem 'parallel_tests'
25
- gem 'rake'
26
- gem 'rspec'
27
- gem 'selenium-webdriver'
28
- gem 'webdrivers'
29
-
30
- EOF
31
- gemfile.result(binding)
32
- end
33
-
34
- def self.example_page
35
- gemfile = ERB.new <<~EOF
36
- require_relative '../abstract/abstract_page'
37
- require_relative '../components/header_component'
38
- require_relative '../../helpers/selenium_helper'
39
-
40
- class LoginPage < AbstractPage
41
-
42
- def url(_page)
43
- 'index.php?rt=account/login'
44
- end
45
-
46
- # Actions
47
-
48
- def login(username, password)
49
- username_field.send_keys username
50
- password_field.send_keys password
51
- login_button.click_when_present
52
- end
53
-
54
- def header
55
- HeaderComponent.new(driver.find_element(class: 'menu_text'))
56
- end
57
-
58
- private
59
-
60
- # Elements
61
-
62
- def username_field
63
- driver.find_element(id: 'loginFrm_loginname')
64
- end
65
-
66
- def password_field
67
- driver.find_element(id: 'loginFrm_password')
68
- end
69
-
70
- def login_button
71
- driver.find_element(xpath: "//button[@title='Login']")
72
- end
73
- end
74
-
75
-
76
-
77
- EOF
78
- gemfile.result(binding)
79
- end
80
-
81
- def self.abstract_page
82
- abstract_file = ERB.new <<~EOF
83
- require_relative '../components/header_component'
84
- require_relative 'abstract_page_object'
85
- require 'rspec'
86
-
87
- class AbstractPage < AbstractPageObject
88
- include RSpec::Matchers
89
-
90
- def visit(*page)
91
- driver.navigate.to full_url(page.first)
92
- end
93
-
94
- def full_url(*page)
95
- "\#{base_url}\#{url(*page)}"
96
- end
97
-
98
- def base_url
99
- 'https://automationteststore.com/'
100
- end
101
-
102
- def url(_page)
103
- raise 'Url must be defined on child pages'
104
- end
105
-
106
- def header
107
- HeaderComponent.new(driver.find_element(css: 'header'))
108
- end
109
- end
110
-
111
- EOF
112
- abstract_file.result(binding)
113
- end
114
-
115
- def self.abstract_component
116
- abstract_file = ERB.new <<~EOF
117
- require_relative '../../helpers/raider'
118
-
119
- class AbstractComponent
120
- def initialize(component)
121
- @component = component
122
- end
123
- end
124
- EOF
125
- abstract_file.result(binding)
126
- end
127
-
128
- def self.abstract_page_object
129
- abstract_file = ERB.new <<~EOF
130
- require_relative '../../helpers/raider'
131
-
132
- class AbstractPageObject
133
- extend Raider::PomHelper
134
-
135
- def driver
136
- Raider::DriverHelper.driver
137
- end
138
- end
139
-
140
- EOF
141
- abstract_file.result(binding)
142
- end
143
-
144
- def self.example_component
145
- page_file = ERB.new <<~EOF
146
- require_relative '../abstract/abstract_component'
147
-
148
- class HeaderComponent < AbstractComponent
149
-
150
- def customer_name
151
- @component.text
152
- end
153
- end
154
-
155
- EOF
156
- page_file.result(binding)
157
- end
158
- end
159
- end
@@ -1,29 +0,0 @@
1
- require_relative '../lib/generators/files/selenium_file_generator'
2
- require_relative 'spec_helper'
3
-
4
- describe RubyRaider::SeleniumFileGenerator do
5
- it 'creates a login page file' do
6
- expect(File.exist?("#{@project_name}/page_objects/pages/login_page.rb")).to be_truthy
7
- end
8
-
9
- it 'creates an abstract page file' do
10
- expect(File.exist?("#{@project_name}/page_objects/abstract/abstract_page.rb")).to be_truthy
11
- end
12
-
13
- it 'creates an abstract page object file' do
14
- expect(File.exist?("#{@project_name}/page_objects/abstract/abstract_page_object.rb")).to be_truthy
15
- end
16
-
17
- it 'creates an abstract component file' do
18
- expect(File.exist?("#{@project_name}/page_objects/abstract/abstract_component.rb")).to be_truthy
19
- end
20
-
21
- it 'creates a component file' do
22
- expect(File.exist?("#{@project_name}/page_objects/components/header_component.rb")).to be_truthy
23
- end
24
-
25
- it 'creates a gemfile file' do
26
- expect(File.exist?("#{@project_name}/Gemfile")).to be_truthy
27
- end
28
- end
29
-