ruby_raider 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -6
  3. data/README.md +5 -1
  4. data/Rakefile +2 -2
  5. data/lib/commands/scaffolding_commands.rb +2 -2
  6. data/lib/generators/automation_generator.rb +14 -10
  7. data/lib/generators/cucumber_generator.rb +10 -2
  8. data/lib/generators/menu_generator.rb +10 -6
  9. data/lib/generators/rspec_generator.rb +9 -1
  10. data/lib/generators/templates/automation/abstract_component.tt +2 -0
  11. data/lib/generators/templates/automation/abstract_page.tt +0 -1
  12. data/lib/generators/templates/automation/appium_settings.tt +5 -8
  13. data/lib/generators/templates/automation/component.tt +1 -1
  14. data/lib/generators/templates/automation/home_page.tt +9 -5
  15. data/lib/generators/templates/automation/login_page.tt +0 -2
  16. data/lib/generators/templates/automation/partials/android_settings.tt +8 -0
  17. data/lib/generators/templates/automation/partials/element.tt +3 -3
  18. data/lib/generators/templates/automation/partials/initialize_selector.tt +4 -0
  19. data/lib/generators/templates/automation/partials/ios_settings.tt +8 -0
  20. data/lib/generators/templates/automation/partials/selenium_login.tt +3 -3
  21. data/lib/generators/templates/automation/partials/watir_login.tt +3 -3
  22. data/lib/generators/templates/automation/pdp_page.tt +22 -0
  23. data/lib/generators/templates/cucumber/feature.tt +9 -0
  24. data/lib/generators/templates/cucumber/partials/appium_env.tt +7 -5
  25. data/lib/generators/templates/cucumber/partials/driver_world.tt +1 -0
  26. data/lib/generators/templates/cucumber/partials/mobile_steps.tt +8 -11
  27. data/lib/generators/templates/cucumber/partials/watir_world.tt +1 -0
  28. data/lib/generators/templates/cucumber/partials/web_steps.tt +1 -1
  29. data/lib/generators/templates/cucumber/world.tt +5 -0
  30. data/lib/generators/templates/helpers/driver_helper.tt +0 -1
  31. data/lib/generators/templates/helpers/partials/select_driver.tt +5 -4
  32. data/lib/generators/templates/rspec/spec.tt +8 -13
  33. data/ruby_raider.gemspec +2 -1
  34. data/spec/automation_generator_spec.rb +36 -154
  35. data/spec/common_generator_spec.rb +27 -112
  36. data/spec/cucumber_generator_spec.rb +15 -54
  37. data/spec/helpers_generator_spec.rb +57 -94
  38. data/spec/rspec_generator_spec.rb +13 -44
  39. data/spec/scaffolding_commands_spec.rb +162 -0
  40. data/spec/spec_helper.rb +20 -0
  41. metadata +23 -5
  42. data/lib/generators/templates/automation/confirmation_page.tt +0 -19
  43. data/lib/generators/templates/automation/partials/appium_login.tt +0 -28
  44. data/spec/scaffolding_spec.rb +0 -234
@@ -4,60 +4,29 @@ require_relative '../lib/generators/rspec_generator'
4
4
  require_relative 'spec_helper'
5
5
 
6
6
  describe RspecGenerator do
7
- context 'with selenium' do
8
- before(:all) do
9
- @name = 'rspec-selenium'
10
- RspecGenerator.new(['selenium', 'rspec', @name]).invoke_all
11
- end
12
-
7
+ shared_examples 'creates rspec files' do |project_name, file_name|
13
8
  it 'creates a spec file' do
14
- expect(File.exist?("#{@name}/spec/login_page_spec.rb")).to be_truthy
9
+ expect(File).to exist("#{project_name}/spec/#{file_name}_page_spec.rb")
15
10
  end
16
11
 
17
12
  it 'creates the base spec file' do
18
- expect(File.exist?("#{@name}/spec/base_spec.rb")).to be_truthy
19
- end
20
-
21
- after(:all) do
22
- FileUtils.rm_rf(@name)
13
+ expect(File).to exist("#{project_name}/spec/base_spec.rb")
23
14
  end
24
15
  end
25
16
 
26
- context 'with watir' do
27
- before(:all) do
28
- @name = 'rspec-watir'
29
- RspecGenerator.new(['watir', 'rspec', @name]).invoke_all
30
- end
31
-
32
- it 'creates a spec file' do
33
- expect(File.exist?("#{@name}/spec/login_page_spec.rb")).to be_truthy
34
- end
35
-
36
- it 'creates the base spec file' do
37
- expect(File.exist?("#{@name}/spec/base_spec.rb")).to be_truthy
38
- end
39
-
40
- after(:all) do
41
- FileUtils.rm_rf(@name)
42
- end
17
+ context 'with rspec and selenium' do
18
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}", 'login'
43
19
  end
44
20
 
45
- context 'with appium' do
46
- before(:all) do
47
- @name = 'rspec-appium'
48
- RspecGenerator.new(['appium_ios', 'rspec', @name]).invoke_all
49
- end
50
-
51
- it 'creates a spec file' do
52
- expect(File.exist?("#{@name}/spec/login_page_spec.rb")).to be_truthy
53
- end
21
+ context 'with rspec and watir' do
22
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.last}", 'login'
23
+ end
54
24
 
55
- it 'creates the base spec file' do
56
- expect(File.exist?("#{@name}/spec/base_spec.rb")).to be_truthy
57
- end
25
+ context 'with rspec and appium android' do
26
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES.first}", 'pdp'
27
+ end
58
28
 
59
- after(:all) do
60
- FileUtils.rm_rf(@name)
61
- end
29
+ context 'with rspec and appium ios' do
30
+ include_examples 'creates rspec files', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[1]}", 'pdp'
62
31
  end
63
32
  end
@@ -0,0 +1,162 @@
1
+ require 'pathname'
2
+ require 'yaml'
3
+ require_relative '../lib/generators/common_generator'
4
+ require_relative '../lib/commands/scaffolding_commands'
5
+ require_relative '../lib/scaffolding/scaffolding'
6
+ require_relative 'spec_helper'
7
+
8
+ describe ScaffoldingCommands do
9
+ let(:scaffold) { described_class }
10
+ let(:name) { 'test' }
11
+
12
+ orig_dir = Dir.pwd
13
+
14
+ after do
15
+ Dir.chdir orig_dir
16
+ end
17
+
18
+ context 'with a spec folder' do
19
+ let(:new_path) { 'test_folder' }
20
+
21
+ path = "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
22
+
23
+ before do
24
+ Dir.chdir path
25
+ end
26
+
27
+ it 'scaffolds for rspec creating a spec' do
28
+ scaffold.new.invoke(:scaffold, nil, %W[#{name}])
29
+ expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
30
+ end
31
+
32
+ it 'scaffolds for rspec creating a page' do
33
+ scaffold.new.invoke(:scaffold, nil, %W[#{name}])
34
+ expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
35
+ end
36
+
37
+ it 'deletes a spec' do
38
+ scaffold.new.invoke(:spec, nil, %w[login --delete])
39
+ expect(Pathname.new('spec/login_spec.rb')).not_to be_file
40
+ end
41
+
42
+ it 'deletes a helper' do
43
+ scaffold.new.invoke(:helper, nil, %w[driver --delete])
44
+ expect(Pathname.new('helpers/driver_helper.rb')).not_to be_file
45
+ end
46
+
47
+ it 'creates a page' do
48
+ scaffold.new.invoke(:page, nil, %W[#{name}])
49
+ expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
50
+ end
51
+
52
+ it 'changes the path for specs' do
53
+ scaffold.new.invoke(:path, nil, %W[#{path} -s])
54
+ config = YAML.load_file('config/config.yml')
55
+ expect(config['spec_path']).to eql path
56
+ end
57
+
58
+ it 'updates the url' do
59
+ scaffold.new.invoke(:url, nil, %w[test.com])
60
+ config = YAML.load_file('config/config.yml')
61
+ expect(config['url']).to eql 'test.com'
62
+ end
63
+
64
+ it 'updates the browser' do
65
+ scaffold.new.invoke(:browser, nil, %w[:firefox])
66
+ config = YAML.load_file('config/config.yml')
67
+ expect(config['browser']).to eql ':firefox'
68
+ end
69
+
70
+ it 'updates the browser options' do
71
+ scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless start-maximized start-fullscreen])
72
+ config = YAML.load_file('config/config.yml')
73
+ expect(config['browser_options']).to eql %w[headless start-maximized start-fullscreen]
74
+ end
75
+
76
+ it 'creates a page with a path' do
77
+ scaffold.new.invoke(:page, nil, %W[#{name} --path #{new_path}])
78
+ expect(Pathname.new("#{new_path}/#{name}_page.rb")).to be_file
79
+ end
80
+
81
+ it 'creates a spec' do
82
+ scaffold.new.invoke(:spec, nil, %W[#{name} --path #{new_path}])
83
+ expect(Pathname.new("#{new_path}/#{name}_spec.rb")).to be_file
84
+ end
85
+ end
86
+
87
+ context 'with a features folder' do
88
+ let(:new_path) { 'test_folder' }
89
+
90
+ path = "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
91
+
92
+ before do
93
+ Dir.chdir path
94
+ end
95
+
96
+ it 'scaffolds for cucumber creating a feature' do
97
+ scaffold.new.invoke(:scaffold, nil, %W[#{name}])
98
+ expect(Pathname.new("features/#{name}.feature")).to be_file
99
+ end
100
+
101
+ it 'scaffolds for cucumber creating a page' do
102
+ scaffold.new.invoke(:scaffold, nil, %W[#{name}])
103
+ expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
104
+ end
105
+
106
+ it 'creates a helper' do
107
+ scaffold.new.invoke(:helper, nil, %W[#{name}])
108
+ expect(Pathname.new("helpers/#{name}_helper.rb")).to be_file
109
+ end
110
+
111
+ it 'deletes a page' do
112
+ scaffold.new.invoke(:page, nil, %w[login --delete])
113
+ expect(Pathname.new('page_objects/pages/login_page.rb')).not_to be_file
114
+ end
115
+
116
+ it 'deletes a feature' do
117
+ scaffold.new.invoke(:feature, nil, %w[login --delete])
118
+ expect(Pathname.new('features/login.feature')).not_to be_file
119
+ end
120
+
121
+ it 'changes the path for pages' do
122
+ scaffold.new.invoke(:path, nil, %W[#{path}])
123
+ config = YAML.load_file('config/config.yml')
124
+ expect(config['page_path']).to eql path
125
+ end
126
+
127
+ it 'changes the path for features' do
128
+ scaffold.new.invoke(:path, nil, %W[#{path} -f])
129
+ config = YAML.load_file('config/config.yml')
130
+ expect(config['feature_path']).to eql path
131
+ end
132
+
133
+ it 'updates only the browser options' do
134
+ scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless])
135
+ config = YAML.load_file('config/config.yml')
136
+ expect(config['browser_options']).to eql %w[headless]
137
+ end
138
+
139
+ it 'deletes the browser options when passed with the delete parameter' do
140
+ scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless --delete])
141
+ config = YAML.load_file('config/config.yml')
142
+ expect(config['browser_options']).to be_nil
143
+ end
144
+
145
+ it 'deletes the browser options' do
146
+ scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless])
147
+ scaffold.new.invoke(:browser, nil, %w[--delete])
148
+ config = YAML.load_file('config/config.yml')
149
+ expect(config['browser_options']).to be_nil
150
+ end
151
+
152
+ it 'creates a feature' do
153
+ scaffold.new.invoke(:feature, nil, %W[#{name} --path #{new_path}])
154
+ expect(Pathname.new("#{new_path}/#{name}.feature")).to be_file
155
+ end
156
+
157
+ it 'creates a helper with a path' do
158
+ scaffold.new.invoke(:helper, nil, %W[#{name} --path #{new_path}])
159
+ expect(Pathname.new("#{new_path}/#{name}_helper.rb")).to be_file
160
+ end
161
+ end
162
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,3 +2,23 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'rspec'
5
+ require_relative '../lib/generators/menu_generator'
6
+
7
+ AUTOMATION_TYPES = %w[android ios selenium watir].freeze
8
+ FRAMEWORKS = %w[cucumber rspec].freeze
9
+
10
+ RSpec.configure do |config|
11
+ config.before(:all) do
12
+ FRAMEWORKS.each do |framework|
13
+ AUTOMATION_TYPES.each do |automation|
14
+ MenuGenerator.new("#{framework}_#{automation}").generate_framework(automation, framework)
15
+ end
16
+ end
17
+ end
18
+
19
+ config.after(:all) do
20
+ FRAMEWORKS.each do |framework|
21
+ AUTOMATION_TYPES.each { |automation| FileUtils.rm_rf("#{framework}_#{automation}") }
22
+ end
23
+ end
24
+ 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.0
4
+ version: 0.4.2
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-09-16 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.27'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.15.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.15.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -143,17 +157,18 @@ files:
143
157
  - lib/generators/templates/automation/abstract_page.tt
144
158
  - lib/generators/templates/automation/appium_settings.tt
145
159
  - lib/generators/templates/automation/component.tt
146
- - lib/generators/templates/automation/confirmation_page.tt
147
160
  - lib/generators/templates/automation/home_page.tt
148
161
  - lib/generators/templates/automation/login_page.tt
149
- - lib/generators/templates/automation/partials/appium_login.tt
162
+ - lib/generators/templates/automation/partials/android_settings.tt
150
163
  - lib/generators/templates/automation/partials/element.tt
151
164
  - lib/generators/templates/automation/partials/initialize_selector.tt
165
+ - lib/generators/templates/automation/partials/ios_settings.tt
152
166
  - lib/generators/templates/automation/partials/require_raider.tt
153
167
  - lib/generators/templates/automation/partials/selenium_login.tt
154
168
  - lib/generators/templates/automation/partials/url_methods.tt
155
169
  - lib/generators/templates/automation/partials/visit_method.tt
156
170
  - lib/generators/templates/automation/partials/watir_login.tt
171
+ - lib/generators/templates/automation/pdp_page.tt
157
172
  - lib/generators/templates/common/config.tt
158
173
  - lib/generators/templates/common/gemfile.tt
159
174
  - lib/generators/templates/common/partials/automation_gems.tt
@@ -162,11 +177,14 @@ files:
162
177
  - lib/generators/templates/cucumber/env.tt
163
178
  - lib/generators/templates/cucumber/feature.tt
164
179
  - lib/generators/templates/cucumber/partials/appium_env.tt
180
+ - lib/generators/templates/cucumber/partials/driver_world.tt
165
181
  - lib/generators/templates/cucumber/partials/mobile_steps.tt
166
182
  - lib/generators/templates/cucumber/partials/selenium_appium_env.tt
167
183
  - lib/generators/templates/cucumber/partials/watir_env.tt
184
+ - lib/generators/templates/cucumber/partials/watir_world.tt
168
185
  - lib/generators/templates/cucumber/partials/web_steps.tt
169
186
  - lib/generators/templates/cucumber/steps.tt
187
+ - lib/generators/templates/cucumber/world.tt
170
188
  - lib/generators/templates/helpers/allure_helper.tt
171
189
  - lib/generators/templates/helpers/browser_helper.tt
172
190
  - lib/generators/templates/helpers/driver_helper.tt
@@ -195,7 +213,7 @@ files:
195
213
  - spec/cucumber_generator_spec.rb
196
214
  - spec/helpers_generator_spec.rb
197
215
  - spec/rspec_generator_spec.rb
198
- - spec/scaffolding_spec.rb
216
+ - spec/scaffolding_commands_spec.rb
199
217
  - spec/spec_helper.rb
200
218
  homepage: https://github.com/RubyRaider/ruby_raider
201
219
  licenses:
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../abstract/abstract_page'
4
-
5
- class ConfirmationPage < AbstractPage
6
- #Values
7
-
8
- def login_message
9
- @driver.wait { message_element }.text
10
- end
11
-
12
- private
13
-
14
- # Elements
15
-
16
- def message_element
17
- @driver.find_element(accessibility_id: 'You are logged in as alice')
18
- end
19
- end
@@ -1,28 +0,0 @@
1
- require_relative '../abstract/abstract_page'
2
-
3
- class LoginPage < AbstractPage
4
-
5
- # Actions
6
-
7
- def login(username, password)
8
- username_field.send_keys username
9
- password_field.send_keys password
10
- login_button.click
11
- end
12
-
13
- private
14
-
15
- # Elements
16
-
17
- def username_field
18
- @driver.find_element(xpath: "//XCUIElementTypeTextField[@name=\"username\"]")
19
- end
20
-
21
- def password_field
22
- @driver.find_element(xpath: "//XCUIElementTypeSecureTextField[@name=\"password\"]")
23
- end
24
-
25
- def login_button
26
- @driver.find_elements(xpath: "//XCUIElementTypeOther[@name=\"loginBtn\"]").last
27
- end
28
- end
@@ -1,234 +0,0 @@
1
- require 'pathname'
2
- require 'yaml'
3
- require_relative '../lib/generators/common_generator'
4
- require_relative '../lib/commands/scaffolding_commands'
5
- require_relative 'spec_helper'
6
-
7
- describe ScaffoldingCommands do
8
- let(:scaffold) { ScaffoldingCommands }
9
- let(:name) { 'test' }
10
-
11
- context 'with a spec folder' do
12
- before(:all) do
13
- ScaffoldingCommands.new.invoke(:config)
14
- end
15
-
16
- it 'scaffolds for rspec' do
17
- scaffold.new.invoke(:scaffold, nil, %W[#{name}])
18
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
19
- expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
20
- end
21
- end
22
-
23
- context 'with a features folder' do
24
- it 'scaffolds for cucumber' do
25
- FileUtils.mkdir 'features'
26
- scaffold.new.invoke(:scaffold, nil, %W[#{name}])
27
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
28
- expect(Pathname.new("features/#{name}.feature")).to be_file
29
- end
30
- end
31
-
32
- after(:all) do
33
- folders = %w[test config page_objects features]
34
- folders.each do |folder|
35
- FileUtils.rm_rf(folder)
36
- end
37
- FileUtils.rm('spec/test_spec.rb') if Pathname.new('spec/test_spec.rb').exist?
38
- end
39
-
40
- context 'with path from config file' do
41
- before(:all) do
42
- ScaffoldingCommands.new.invoke(:config)
43
- end
44
-
45
- it 'creates a page' do
46
- scaffold.new.invoke(:page, nil, %W[#{name}])
47
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
48
- end
49
-
50
- it 'creates a feature' do
51
- scaffold.new.invoke(:feature, nil, %W[#{name}])
52
- expect(Pathname.new("features/#{name}.feature")).to be_file
53
- end
54
-
55
- it 'creates a spec' do
56
- scaffold.new.invoke(:spec, nil, %W[#{name}])
57
- expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
58
- end
59
-
60
- it 'creates a helper' do
61
- scaffold.new.invoke(:helper, nil, %W[#{name}])
62
- expect(Pathname.new("helpers/#{name}_helper.rb")).to be_file
63
- end
64
-
65
- it 'deletes a page' do
66
- scaffold.new.invoke(:page, nil, %W[#{name}])
67
- scaffold.new.invoke(:page, nil, %W[#{name} --delete])
68
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to_not be_file
69
- end
70
-
71
- it 'deletes a feature' do
72
- scaffold.new.invoke(:feature, nil, %W[#{name}])
73
- scaffold.new.invoke(:feature, nil, %W[#{name} --delete])
74
- expect(Pathname.new("features/#{name}.feature")).to_not be_file
75
- end
76
-
77
- it 'deletes a spec' do
78
- scaffold.new.invoke(:spec, nil, %W[#{name}])
79
- scaffold.new.invoke(:spec, nil, %W[#{name} --delete])
80
- expect(Pathname.new("spec/#{name}_spec.rb")).to_not be_file
81
- end
82
-
83
- it 'deletes a helper' do
84
- scaffold.new.invoke(:helper, nil, %W[#{name}])
85
- scaffold.new.invoke(:helper, nil, %W[#{name} --delete])
86
- expect(Pathname.new("helpers/#{name}_helper.rb")).to_not be_file
87
- end
88
-
89
- after(:all) do
90
- folders = %w[test config page_objects features helpers]
91
- folders.each do |folder|
92
- FileUtils.rm_rf(folder)
93
- end
94
- FileUtils.rm('spec/test_spec.rb') if Pathname.new('spec/test_spec.rb').exist?
95
- end
96
- end
97
-
98
- context 'with path option' do
99
- let(:path) { 'test_folder' }
100
-
101
- it 'creates a page' do
102
- scaffold.new.invoke(:page, nil, %W[#{name} --path #{path}])
103
- expect(Pathname.new("#{path}/#{name}_page.rb")).to be_file
104
- end
105
-
106
- it 'creates a feature' do
107
- scaffold.new.invoke(:feature, nil, %W[#{name} --path #{path}])
108
- expect(Pathname.new("#{path}/#{name}.feature")).to be_file
109
- end
110
-
111
- it 'creates a spec' do
112
- scaffold.new.invoke(:spec, nil, %W[#{name} --path #{path}])
113
- expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
114
- end
115
-
116
- it 'creates a helper' do
117
- scaffold.new.invoke(:helper, nil, %W[#{name} --path #{path}])
118
- expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
119
- end
120
-
121
- after(:each) do
122
- FileUtils.rm_rf(path)
123
- end
124
- end
125
-
126
- context 'changes the default path' do
127
- let(:path) { 'test_folder' }
128
-
129
- before(:all) do
130
- ScaffoldingCommands.new.invoke(:config)
131
- end
132
-
133
- it 'changes the path for pages' do
134
- scaffold.new.invoke(:path, nil, %W[#{path}])
135
- config = YAML.load_file('config/config.yml')
136
- expect(config['page_path']).to eql path
137
- end
138
-
139
- it 'changes the path for features' do
140
- scaffold.new.invoke(:path, nil, %W[#{path} -f])
141
- config = YAML.load_file('config/config.yml')
142
- expect(config['feature_path']).to eql path
143
- end
144
-
145
- it 'changes the path for specs' do
146
- scaffold.new.invoke(:path, nil, %W[#{path} -s])
147
- config = YAML.load_file('config/config.yml')
148
- expect(config['spec_path']).to eql path
149
- end
150
-
151
- it 'creates page' do
152
- scaffold.new.invoke(:path, nil, %W[#{path}])
153
- scaffold.new.invoke(:page, nil, %W[#{name}])
154
- expect(Pathname.new("#{path}/#{name}_page.rb")).to be_file
155
- end
156
-
157
- it 'creates feature' do
158
- scaffold.new.invoke(:path, nil, %W[#{path} -f])
159
- scaffold.new.invoke(:feature, nil, %W[#{name}])
160
- expect(Pathname.new("#{path}/#{name}.feature")).to be_file
161
- end
162
-
163
- it 'creates spec' do
164
- scaffold.new.invoke(:path, nil, %W[#{path} -s])
165
- scaffold.new.invoke(:spec, nil, %W[#{name}])
166
- expect(Pathname.new("#{path}/#{name}_spec.rb")).to be_file
167
- end
168
-
169
- it 'creates spec' do
170
- scaffold.new.invoke(:path, nil, %W[#{path} -h])
171
- scaffold.new.invoke(:helper, nil, %W[#{name}])
172
- expect(Pathname.new("#{path}/#{name}_helper.rb")).to be_file
173
- end
174
-
175
- after(:all) do
176
- folders = %w[test_folder test config]
177
- folders.each do |folder|
178
- FileUtils.rm_rf(folder)
179
- end
180
- end
181
- end
182
-
183
- context 'updates the config file' do
184
- before(:all) do
185
- CommonGenerator.new(%w[rspec selenium test]).invoke(:generate_config_file)
186
- FileUtils.cp_lr('test/config', './')
187
- end
188
-
189
- it 'updates the url' do
190
- scaffold.new.invoke(:url, nil, %W[test.com])
191
- config = YAML.load_file('config/config.yml')
192
- expect(config['url']).to eql 'test.com'
193
- end
194
-
195
- it 'updates the browser' do
196
- scaffold.new.invoke(:browser, nil, %W[:firefox])
197
- config = YAML.load_file('config/config.yml')
198
- expect(config['browser']).to eql ':firefox'
199
- end
200
-
201
- it 'updates the browser and the browser options' do
202
- scaffold.new.invoke(:browser, nil, %W[:firefox --opts headless start-maximized start-fullscreen])
203
- config = YAML.load_file('config/config.yml')
204
- expect(config['browser']).to eql ':firefox'
205
- expect(config['browser_options']).to eql %W[headless start-maximized start-fullscreen]
206
- end
207
-
208
- it 'updates only the browser options' do
209
- scaffold.new.invoke(:browser, nil, %W[:firefox --opts headless])
210
- config = YAML.load_file('config/config.yml')
211
- expect(config['browser_options']).to eql %w[headless]
212
- end
213
-
214
- it 'deletes the browser options when passed with the delete parameter' do
215
- scaffold.new.invoke(:browser, nil, %W[:firefox --opts headless --delete])
216
- config = YAML.load_file('config/config.yml')
217
- expect(config['browser_options']).to be_nil
218
- end
219
-
220
- it 'deletes the browser options' do
221
- scaffold.new.invoke(:browser, nil, %W[:firefox --opts headless])
222
- scaffold.new.invoke(:browser, nil, %W[--delete])
223
- config = YAML.load_file('config/config.yml')
224
- expect(config['browser_options']).to be_nil
225
- end
226
-
227
- after(:all) do
228
- folders = %w[test config]
229
- folders.each do |folder|
230
- FileUtils.rm_rf(folder)
231
- end
232
- end
233
- end
234
- end