ruby_raider 0.6.6 → 0.6.7

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: cbbff7b5c37609e5abb70fa66775333d715688e32495748c0e1fb76c53e3daac
4
- data.tar.gz: 96eec8c6122e9922963b0abd6a1435d9d9d0de7099b4ac554e76f7882b40d8be
3
+ metadata.gz: d9b2ca2ebc2ac13cd26f9b249e5e18c878e41de247516a056fa84f9e9a264ff4
4
+ data.tar.gz: 060d5b9c68c55c7d3e0244fb510459f2e531c209c8baf90f0e21b7c8a9f75bf3
5
5
  SHA512:
6
- metadata.gz: 5805bd62e25e138b3a40f08086e839775ba74727fa063cabee8c281f6c1371658300833b85e580a9011a75a6417c46aeb11fd8e357e99ed387d34fda34d2b812
7
- data.tar.gz: 7ee415912f9e681521f780aa990045a10ac4d4661db04a8c9b1ead77bf183369d488855cd6ec4fa4541885dc103b679b52b79da8b902b1b7c8cd28c78b76abee
6
+ metadata.gz: 99ffee60cf5bf77aaa9781b0ee2e9d3625589d7533ed9ee18672dffdd39685d16e7cdaf348258d51ef9f81c544802a418027888752b5b7fc9fbdd8dfc5fa3740
7
+ data.tar.gz: 832494ce3b7af149c441ba70ba790ef2ccc4147c19c3458879e4e7e13a4bc77dc9900416df6a23ea41f6ddaf49453e017f5c0fe58764faa34f027cc124896c7c
@@ -108,8 +108,6 @@ class RunnerComponents < BaseComponent
108
108
  button(button_test_name) do
109
109
  on_clicked do
110
110
  Scaffolding.new([@test_name.text]).generate_spec
111
- extension = @folder == 'spec' ? '.rb' : '.feature'
112
- @editable_files.selected_item = "#{@folder}/#{@helper_name.text}#{extension}"
113
111
  end
114
112
  end
115
113
  @test_name = entry do
@@ -120,10 +118,6 @@ class RunnerComponents < BaseComponent
120
118
  button('Create Page') do
121
119
  on_clicked do
122
120
  Scaffolding.new([@page_name.text]).generate_class
123
- page_item = "page_objects/pages/#{@page_name.text}_page.rb"
124
- @all_files.push(page_item)
125
- @editable_files.items.append(page_item)
126
- @editable_files.selected_item = page_item
127
121
  end
128
122
  end
129
123
  @page_name = entry do
@@ -134,7 +128,6 @@ class RunnerComponents < BaseComponent
134
128
  button('Create Helper') do
135
129
  on_clicked do
136
130
  Scaffolding.new([@helper_name.text]).generate_helper
137
- @editable_files.selected_item = "helpers/#{@helper_name.text}_helper.rb"
138
131
  end
139
132
  end
140
133
  @helper_name = entry do
@@ -155,8 +148,7 @@ class RunnerComponents < BaseComponent
155
148
 
156
149
  on_selected do |items|
157
150
  if @folder_exist
158
- @selected_path = @editable_files.selected_item
159
- path = @selected_path || @editable_files.items.last
151
+ path = items.selected_item
160
152
  @edit_file = File.open(path)
161
153
  @edit_box.text = @edit_file.read
162
154
  end
@@ -7,12 +7,15 @@ class AutomationExamplesGenerator < Generator
7
7
  if mobile_platform?
8
8
  generate_home_page
9
9
  generate_pdp_page
10
+ elsif visual_selected?
11
+ generate_login_page
12
+ generate_app_page
10
13
  else
14
+ generate_model_factory
15
+ generate_model_data
16
+ generate_header_component
11
17
  generate_login_page
12
- generate_header_component unless visual_selected?
13
18
  end
14
-
15
- generate_app_page if visual_selected?
16
19
  end
17
20
 
18
21
  private
@@ -36,4 +39,12 @@ class AutomationExamplesGenerator < Generator
36
39
  def generate_app_page
37
40
  template('app_page.tt', "#{name}/page_objects/pages/app_page.rb")
38
41
  end
42
+
43
+ def generate_model_factory
44
+ template('factory.tt', "#{name}/models/model_factory.rb")
45
+ end
46
+
47
+ def generate_model_data
48
+ template('data.tt', "#{name}/models/data/users.yml")
49
+ end
39
50
  end
@@ -11,6 +11,10 @@ class CucumberExamplesGenerator < Generator
11
11
  template('steps.tt', "#{name}/features/step_definitions/#{template_name}_steps.rb")
12
12
  end
13
13
 
14
+ def generate_user_factory
15
+ template('steps.tt', "#{name}/models/user_factory.rb")
16
+ end
17
+
14
18
  def template_name
15
19
  @template_name ||= (@_initializer.first & %w[android ios cross_platform]).empty? ? 'login' : 'home'
16
20
  end
@@ -10,4 +10,8 @@ class CucumberGenerator < Generator
10
10
  def generate_world
11
11
  template('world.tt', "#{name}/world.rb")
12
12
  end
13
+
14
+ def generate_cucumber_file
15
+ template('cucumber.tt', "#{name}/cucumber.yml")
16
+ end
13
17
  end
@@ -0,0 +1 @@
1
+ default: --format AllureCucumber::CucumberFormatter --out allure-results --publish-quiet
@@ -5,6 +5,7 @@ Scenario: A user can login
5
5
  Given I'm a registered user on the login page
6
6
  When I login with my credentials
7
7
  Then I can see the main page
8
+
8
9
  <% else -%>
9
10
  Feature: Home Page
10
11
 
@@ -1 +1,7 @@
1
- World(DriverHelper)
1
+ <% if automation == 'selenium' %>
2
+ require_relative 'models/user_factory'
3
+
4
+ World(DriverHelper, UserFactory)
5
+ <% else %>
6
+ World(DriverHelper)
7
+ <% end %>
@@ -1 +1,3 @@
1
- World(BrowserHelper)
1
+ require_relative 'models/user_factory'
2
+
3
+ World(BrowserHelper, UserFactory)
@@ -2,15 +2,16 @@
2
2
 
3
3
  require_relative '../../page_objects/pages/login_page'
4
4
 
5
- Given("I'm a registered user on the login page") do
6
- @login_page = LoginPage.new(<% if automation == 'watir'%>browser<% else %>driver<% end %>)
7
- @login_page.visit
5
+ Given("I'm a {user} on the login page") do |user|
6
+ @user = user
7
+ @login_page = LoginPage.new(browser)
8
+ @login_page.visit
8
9
  end
9
10
 
10
11
  When('I login with my credentials') do
11
- @login_page.login('aguspe', '12341234')
12
+ @login_page.login(@user['username'], @user['password'])
12
13
  end
13
14
 
14
15
  When('I can see the main page') do
15
- expect(@login_page.header.customer_name).to eq 'Welcome back Agustin'
16
+ expect(@login_page.header.customer_name).to eq "Welcome back #{@user['name']}"
16
17
  end
@@ -0,0 +1,13 @@
1
+ require_relative 'model_factory'
2
+
3
+ class UserFactory < ModelFactory
4
+ def self.for(user)
5
+ super('users')[user]
6
+ end
7
+ end
8
+
9
+ ParameterType(
10
+ name: 'user',
11
+ regexp: /[A-Za-z0-9]+ user/,
12
+ transformer: ->(user) { UserFactory.for(user) }
13
+ )
@@ -1,5 +1,5 @@
1
- <% if %w[watir].include? automation -%>
2
- <%= ERB.new(File.read(File.expand_path('./partials/watir_world.tt', __dir__))).result(binding).strip! -%>
3
- <% else -%>
4
- <%= ERB.new(File.read(File.expand_path('./partials/driver_world.tt', __dir__))).result(binding).strip! -%>
5
- <% end -%>
1
+ <% if automation == 'watir' %>
2
+ <%= ERB.new(File.read(File.expand_path('./partials/watir_world.tt', __dir__))).result(binding).strip! %>
3
+ <% else %>
4
+ <%= ERB.new(File.read(File.expand_path('./partials/driver_world.tt', __dir__))).result(binding).strip! %>
5
+ <% end %>
@@ -27,6 +27,10 @@ class Generator < Thor::Group
27
27
  (args & %w[android ios cross_platform]).count.positive?
28
28
  end
29
29
 
30
+ def web_platform?
31
+ args.include?(%w[selenium watir])
32
+ end
33
+
30
34
  private
31
35
 
32
36
  def _initializer
@@ -14,16 +14,4 @@ class RspecExamplesGenerator < Generator
14
14
 
15
15
  template('spec.tt', "#{name}/spec/pdp_page_spec.rb")
16
16
  end
17
-
18
- def generate_model_factory
19
- return if args.include?(%w[selenium watir])
20
-
21
- template('factory.tt', "#{name}/models/model_factory.rb")
22
- end
23
-
24
- def generate_model_data
25
- return if args.include?(%w[selenium watir])
26
-
27
- template('data.tt', "#{name}/models/data/users.yml")
28
- end
29
17
  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.6.6'
5
+ s.version = '0.6.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']
@@ -17,6 +17,10 @@ describe CucumberGenerator do
17
17
  expect(File).to exist("#{project_name}/features/support/env.rb")
18
18
  end
19
19
 
20
+ it 'creates an cucumber.yml file' do
21
+ expect(File).to exist("#{project_name}/cucumber.yml")
22
+ end
23
+
20
24
  it 'does not create a spec file' do
21
25
  expect(File).not_to exist("#{project_name}/spec/home_spec.rb")
22
26
  end
@@ -35,11 +39,29 @@ describe CucumberGenerator do
35
39
  expect(File).to exist("#{project_name}/features/support/env.rb")
36
40
  end
37
41
 
42
+ it 'creates an cucumber.yml file' do
43
+ expect(File).to exist("#{project_name}/cucumber.yml")
44
+ end
45
+
38
46
  it 'does not create a spec file' do
39
47
  expect(File).not_to exist("#{project_name}/spec/home_spec.rb")
40
48
  end
41
49
  end
42
50
 
51
+ shared_examples 'creates factories for web projects' do |project_name|
52
+ it 'creates an data file' do
53
+ expect(File).to exist("#{project_name}/models/data/users.yml")
54
+ end
55
+
56
+ it 'creates a model factory' do
57
+ expect(File).to exist("#{project_name}/models/model_factory.rb")
58
+ end
59
+
60
+ it 'creates a user factory' do
61
+ expect(File).to exist("#{project_name}/models/user_factory.rb")
62
+ end
63
+ end
64
+
43
65
  context 'with cucumber and appium android' do
44
66
  include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.first}", 'home'
45
67
  include_examples 'creates cucumber files without examples',
@@ -60,12 +82,14 @@ describe CucumberGenerator do
60
82
 
61
83
  context 'with cucumber and selenium' do
62
84
  include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}", 'login'
85
+ include_examples 'creates factories for web projects', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}", 'login'
63
86
  include_examples 'creates cucumber files without examples',
64
87
  "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}_without_examples", 'login'
65
88
  end
66
89
 
67
90
  context 'with cucumber and watir' do
68
91
  include_examples 'creates cucumber files', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}", 'login'
92
+ include_examples 'creates factories for web projects', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}", 'login'
69
93
  include_examples 'creates cucumber files without examples',
70
94
  "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}_without_examples", 'login'
71
95
  end
@@ -3,7 +3,7 @@ require_relative 'spec_helper'
3
3
  require_relative '../lib/ruby_raider'
4
4
 
5
5
  describe RubyRaider do
6
- shared_examples 'execute framework' do |name|
6
+ shared_examples 'execute web frameworks' do |name|
7
7
  it 'runs the tests' do
8
8
  Bundler.with_unbundled_env do
9
9
  Dir.chdir(name) do
@@ -14,18 +14,18 @@ describe RubyRaider do
14
14
  end
15
15
 
16
16
  context 'with a Rspec and Selenium project' do
17
- include_examples 'execute framework', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
17
+ include_examples 'execute web frameworks', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
18
18
  end
19
19
 
20
20
  context 'with a Rspec and Watir project' do
21
- include_examples 'execute framework', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
21
+ include_examples 'execute web frameworks', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
22
22
  end
23
23
 
24
24
  context 'with a Cucumber and Selenium project' do
25
- include_examples 'execute framework', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
25
+ include_examples 'execute web frameworks', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
26
26
  end
27
27
 
28
28
  context 'with a Cucumber and Watir project' do
29
- include_examples 'execute framework', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
29
+ include_examples 'execute web frameworks', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
30
30
  end
31
31
  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.6.6
4
+ version: 0.6.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-04-07 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -235,6 +235,7 @@ files:
235
235
  - lib/generators/common_generator.rb
236
236
  - lib/generators/cucumber/cucumber_examples_generator.rb
237
237
  - lib/generators/cucumber/cucumber_generator.rb
238
+ - lib/generators/cucumber/templates/cucumber.tt
238
239
  - lib/generators/cucumber/templates/env.tt
239
240
  - lib/generators/cucumber/templates/feature.tt
240
241
  - lib/generators/cucumber/templates/partials/appium_env.tt
@@ -245,6 +246,7 @@ files:
245
246
  - lib/generators/cucumber/templates/partials/watir_world.tt
246
247
  - lib/generators/cucumber/templates/partials/web_steps.tt
247
248
  - lib/generators/cucumber/templates/steps.tt
249
+ - lib/generators/cucumber/templates/user_factory.tt
248
250
  - lib/generators/cucumber/templates/world.tt
249
251
  - lib/generators/generator.rb
250
252
  - lib/generators/helper_generator.rb