howitzer 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/LICENSE +1 -1
  4. data/README.md +16 -16
  5. data/generators/base_generator.rb +1 -1
  6. data/generators/config/config_generator.rb +1 -4
  7. data/generators/config/templates/boot.rb +1 -1
  8. data/generators/config/templates/capybara.rb +1 -3
  9. data/generators/config/templates/default.yml +5 -19
  10. data/generators/config/templates/drivers/browserstack.rb +1 -1
  11. data/generators/config/templates/drivers/crossbrowsertesting.rb +1 -1
  12. data/generators/config/templates/drivers/headless_chrome.rb +1 -1
  13. data/generators/config/templates/drivers/headless_firefox.rb +1 -1
  14. data/generators/config/templates/drivers/sauce.rb +1 -1
  15. data/generators/config/templates/drivers/selenium.rb +1 -1
  16. data/generators/config/templates/drivers/selenium_grid.rb +2 -2
  17. data/generators/config/templates/drivers/testingbot.rb +1 -1
  18. data/generators/cucumber/templates/env.rb +1 -1
  19. data/generators/cucumber/templates/hooks.rb +8 -2
  20. data/generators/cucumber/templates/transformers.rb +1 -1
  21. data/generators/prerequisites/templates/factory_bot.rb +1 -1
  22. data/generators/root/templates/Gemfile.erb +4 -10
  23. data/generators/rspec/templates/spec_helper.rb +4 -4
  24. data/generators/turnip/templates/spec_helper.rb +4 -4
  25. data/generators/web/templates/example_page.rb +1 -1
  26. data/lib/howitzer/cache.rb +1 -1
  27. data/lib/howitzer/capybara_helpers.rb +27 -7
  28. data/lib/howitzer/email.rb +2 -2
  29. data/lib/howitzer/exceptions.rb +21 -21
  30. data/lib/howitzer/gmail_api/client.rb +13 -4
  31. data/lib/howitzer/log.rb +6 -6
  32. data/lib/howitzer/mailgun_api/client.rb +3 -2
  33. data/lib/howitzer/mailgun_api/response.rb +1 -2
  34. data/lib/howitzer/mailtrap_api/client.rb +1 -1
  35. data/lib/howitzer/meta/actions.rb +13 -16
  36. data/lib/howitzer/meta/element.rb +12 -10
  37. data/lib/howitzer/utils/string_extensions.rb +6 -2
  38. data/lib/howitzer/version.rb +1 -1
  39. data/lib/howitzer/web/base_section.rb +1 -1
  40. data/lib/howitzer/web/capybara_methods_proxy.rb +11 -5
  41. data/lib/howitzer/web/element_dsl.rb +104 -45
  42. data/lib/howitzer/web/iframe_dsl.rb +2 -2
  43. data/lib/howitzer/web/page.rb +4 -14
  44. data/lib/howitzer/web/page_dsl.rb +15 -6
  45. data/lib/howitzer/web/page_validator.rb +25 -26
  46. data/lib/howitzer/web/section.rb +5 -2
  47. data/lib/howitzer/web/section_dsl.rb +64 -30
  48. data/lib/howitzer.rb +2 -2
  49. metadata +24 -161
  50. data/.coveralls.yml +0 -1
  51. data/.gitignore +0 -14
  52. data/.rspec +0 -3
  53. data/.rubocop.yml +0 -60
  54. data/.ruby-gemset +0 -1
  55. data/.travis.yml +0 -8
  56. data/Gemfile +0 -14
  57. data/ISSUE_TEMPLATE.md +0 -16
  58. data/MAINTENANCE.md +0 -32
  59. data/Rakefile +0 -38
  60. data/features/cli_help.feature +0 -31
  61. data/features/cli_new.feature +0 -393
  62. data/features/cli_unknown.feature +0 -17
  63. data/features/cli_update.feature +0 -223
  64. data/features/cli_version.feature +0 -14
  65. data/features/step_definitions/common_steps.rb +0 -34
  66. data/features/support/env.rb +0 -1
  67. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  68. data/generators/config/templates/drivers/webkit.rb +0 -6
  69. data/generators/root/templates/.gitignore +0 -21
  70. data/generators/root/templates/.rubocop.yml.erb +0 -56
  71. data/generators/turnip/templates/.rspec +0 -1
  72. data/howitzer.gemspec +0 -39
  73. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  74. data/spec/config/custom.yml +0 -9
  75. data/spec/spec_helper.rb +0 -73
  76. data/spec/support/generator_helper.rb +0 -21
  77. data/spec/support/logger_helper.rb +0 -13
  78. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  79. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  80. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  81. data/spec/support/shared_examples/element_dsl.rb +0 -242
  82. data/spec/support/shared_examples/meta_highlight_xpath.rb +0 -41
  83. data/spec/unit/generators/base_generator_spec.rb +0 -283
  84. data/spec/unit/generators/config_generator_spec.rb +0 -61
  85. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  86. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  87. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  88. data/spec/unit/generators/root_generator_spec.rb +0 -86
  89. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  90. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  91. data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
  92. data/spec/unit/generators/templates/rspec_spec.rb +0 -88
  93. data/spec/unit/generators/templates/turnip_spec.rb +0 -98
  94. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  95. data/spec/unit/generators/web_generator_spec.rb +0 -52
  96. data/spec/unit/lib/cache_spec.rb +0 -85
  97. data/spec/unit/lib/capybara_helpers_spec.rb +0 -730
  98. data/spec/unit/lib/email_spec.rb +0 -186
  99. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  100. data/spec/unit/lib/howitzer_spec.rb +0 -92
  101. data/spec/unit/lib/init_spec.rb +0 -2
  102. data/spec/unit/lib/log_spec.rb +0 -122
  103. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  104. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  105. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  106. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  107. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  108. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  109. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  110. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  111. data/spec/unit/lib/meta/element_spec.rb +0 -59
  112. data/spec/unit/lib/meta/entry_spec.rb +0 -77
  113. data/spec/unit/lib/meta/iframe_spec.rb +0 -66
  114. data/spec/unit/lib/meta/section_spec.rb +0 -43
  115. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  116. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  117. data/spec/unit/lib/web/element_dsl_spec.rb +0 -31
  118. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  119. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  120. data/spec/unit/lib/web/page_spec.rb +0 -385
  121. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  122. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  123. data/spec/unit/lib/web/section_spec.rb +0 -70
  124. data/spec/unit/version_spec.rb +0 -8
@@ -1,730 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/capybara_helpers'
3
-
4
- RSpec.describe Howitzer::CapybaraHelpers do
5
- include Howitzer::CapybaraHelpers
6
-
7
- let(:selenium_driver) { false }
8
- let(:selenium_grid_driver) { false }
9
- let(:sauce_driver) { false }
10
- let(:test_object) { described_class }
11
-
12
- describe '#cloud_driver?' do
13
- subject { cloud_driver? }
14
- before { allow(Howitzer).to receive(:driver) { driver_setting } }
15
- context 'when sauce driver' do
16
- let(:driver_setting) { :sauce }
17
- it { is_expected.to be_truthy }
18
- end
19
- context 'when testingbot driver' do
20
- let(:driver_setting) { :testingbot }
21
- it { is_expected.to be_truthy }
22
- end
23
- context 'when browserstack driver' do
24
- let(:driver_setting) { :browserstack }
25
- it { is_expected.to be_truthy }
26
- end
27
- context 'when not cloud driver' do
28
- let(:driver_setting) { :poltergeist }
29
- it { is_expected.to be_falsey }
30
- end
31
- context 'when driver specified as String' do
32
- let(:driver_setting) { 'testingbot' }
33
- it { is_expected.to be true }
34
- end
35
- end
36
-
37
- describe '#selenium_driver?' do
38
- subject { selenium_driver? }
39
- before { allow(Howitzer).to receive(:driver) { driver_setting } }
40
- context 'when :selenium' do
41
- let(:driver_setting) { :selenium }
42
- it { is_expected.to be_truthy }
43
- end
44
- context 'when :selenium_grid' do
45
- let(:driver_setting) { :selenium_grid }
46
- it { is_expected.to be_falsey }
47
- end
48
- context 'when not :selenium' do
49
- let(:driver_setting) { :poltergeist }
50
- it { is_expected.to be_falsey }
51
- end
52
- context 'when driver specified as String' do
53
- let(:driver_setting) { 'selenium' }
54
- it { is_expected.to be_truthy }
55
- end
56
- end
57
-
58
- describe '#headless_chrome_driver?' do
59
- subject { headless_chrome_driver? }
60
- before { allow(Howitzer).to receive(:driver) { driver_setting } }
61
- context 'when :headless_chrome' do
62
- let(:driver_setting) { :headless_chrome }
63
- it { is_expected.to be_truthy }
64
- end
65
- context 'when not :headless_chrome' do
66
- let(:driver_setting) { :selenium }
67
- it { is_expected.to be_falsey }
68
- end
69
- context 'when driver specified as String' do
70
- let(:driver_setting) { 'headless_chrome' }
71
- it { is_expected.to be_truthy }
72
- end
73
- end
74
-
75
- describe '#headless_firefox_driver?' do
76
- subject { headless_firefox_driver? }
77
- before { allow(Howitzer).to receive(:driver) { driver_setting } }
78
- context 'when :headless_firefox_driver' do
79
- let(:driver_setting) { :headless_firefox }
80
- it { is_expected.to be_truthy }
81
- end
82
- context 'when not :headless_firefox' do
83
- let(:driver_setting) { :selenium }
84
- it { is_expected.to be_falsey }
85
- end
86
- context 'when driver specified as String' do
87
- let(:driver_setting) { 'headless_firefox' }
88
- it { is_expected.to be_truthy }
89
- end
90
- end
91
-
92
- describe '#selenium_grid_driver?' do
93
- subject { selenium_grid_driver? }
94
- before { allow(Howitzer).to receive(:driver) { driver_setting } }
95
- context 'when :selenium_grid' do
96
- let(:driver_setting) { :selenium_grid }
97
- it { is_expected.to be_truthy }
98
- end
99
- context 'when :selenium' do
100
- let(:driver_setting) { :selenium }
101
- it { is_expected.to be_falsey }
102
- end
103
- context 'when not :selenium' do
104
- let(:driver_setting) { :poltergeist }
105
- it { is_expected.to be_falsey }
106
- end
107
- context 'when driver specified as String' do
108
- let(:driver_setting) { 'selenium_grid' }
109
- it { is_expected.to be_truthy }
110
- end
111
- end
112
-
113
- describe '#ie_browser?' do
114
- subject { ie_browser? }
115
- before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }
116
- context 'when cloud_driver? is TRUE' do
117
- before { allow(self).to receive(:cloud_driver?) { true } }
118
- context 'Howitzer.cloud_browser_name = :ie' do
119
- before { allow(Howitzer).to receive(:cloud_browser_name) { :ie } }
120
- it { is_expected.to be_truthy }
121
- end
122
- context 'Howitzer.cloud_browser_name = :iexplore' do
123
- before { allow(Howitzer).to receive(:cloud_browser_name) { :iexplore } }
124
- it { is_expected.to be_truthy }
125
- end
126
- context 'Howitzer.cloud_browser_name = :chrome' do
127
- before { allow(Howitzer).to receive(:cloud_browser_name) { :chrome } }
128
- it { is_expected.to be_falsey }
129
- end
130
- context 'Howitzer.cloud_browser_name is not specified' do
131
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
132
- it do
133
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
134
- end
135
- end
136
- end
137
- context 'when cloud_driver? is FALSE' do
138
- before do
139
- allow(self).to receive(:cloud_driver?) { false }
140
- allow(self).to receive(:selenium_driver?) { selenium_driver }
141
- end
142
- context 'when selenium_driver? is TRUE' do
143
- let(:selenium_driver) { true }
144
- context 'Howitzer.selenium_browser = :ie' do
145
- before { allow(Howitzer).to receive(:selenium_browser) { :ie } }
146
- it { is_expected.to be_truthy }
147
- end
148
- context 'Howitzer.selenium_browser = :iexplore' do
149
- before { allow(Howitzer).to receive(:selenium_browser) { :iexplore } }
150
- it { is_expected.to be_truthy }
151
- end
152
- context 'Howitzer.selenium_browser = :chrome' do
153
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
154
- it { is_expected.to be_falsey }
155
- end
156
- context 'Howitzer.selenium_browser is not specified' do
157
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
158
- it do
159
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
160
- end
161
- end
162
- end
163
- context 'when selenium_driver? is FALSE' do
164
- it { is_expected.to be_falsey }
165
- end
166
- context 'when selenium_grid_driver? is TRUE' do
167
- let(:selenium_grid_driver) { true }
168
- context 'Howitzer.selenium_browser = :ie' do
169
- before { allow(Howitzer).to receive(:selenium_browser) { :ie } }
170
- it { is_expected.to be_truthy }
171
- end
172
- context 'Howitzer.selenium_browser = :iexplore' do
173
- before { allow(Howitzer).to receive(:selenium_browser) { :iexplore } }
174
- it { is_expected.to be_truthy }
175
- end
176
- context 'Howitzer.selenium_browser = :chrome' do
177
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
178
- it { is_expected.to be_falsey }
179
- end
180
- context 'Howitzer.selenium_browser is not specified' do
181
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
182
- it do
183
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
184
- end
185
- end
186
- end
187
- context 'when selenium_grid_driver? is FALSE' do
188
- it { is_expected.to be_falsey }
189
- end
190
- end
191
- context 'when selenium_driver? is TRUE' do
192
- before do
193
- allow(self).to receive(:selenium_driver?) { selenium_driver }
194
- allow(self).to receive(:cloud_driver?) { false }
195
- end
196
- context 'when selenium_driver? is TRUE' do
197
- let(:selenium_driver) { true }
198
- context 'Howitzer.selenium_browser = :ie' do
199
- before { allow(Howitzer).to receive(:selenium_browser) { :ie } }
200
- it { is_expected.to be_truthy }
201
- end
202
- context 'Howitzer.selenium_browser = :iexplore' do
203
- before { allow(Howitzer).to receive(:selenium_browser) { :iexplore } }
204
- it { is_expected.to be_truthy }
205
- end
206
- context 'Howitzer.selenium_browser = :chrome' do
207
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
208
- it { is_expected.to be_falsey }
209
- end
210
- context 'Howitzer.selenium_browser is not specified' do
211
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
212
- it do
213
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
214
- end
215
- end
216
- end
217
- end
218
- context 'when selenium_driver? is FALSE' do
219
- before { allow(self).to receive(:selenium_driver?) { false } }
220
- context 'when cloud_driver? is TRUE' do
221
- before { allow(self).to receive(:cloud_driver?) { true } }
222
- context 'Howitzer.cloud_browser_name = :ie' do
223
- before do
224
- allow(Howitzer).to receive(:cloud_browser_name) { :ie }
225
- allow(Howitzer).to receive(:cloud_browser_version) { 9 }
226
- end
227
- it { is_expected.to be_truthy }
228
- end
229
- context 'Howitzer.cloud_browser_name = :iexplore' do
230
- before do
231
- allow(Howitzer).to receive(:cloud_browser_name) { :iexplore }
232
- allow(Howitzer).to receive(:cloud_browser_version) { 9 }
233
- end
234
- it { is_expected.to be_truthy }
235
- end
236
- context 'Howitzer.cloud_browser_name = :firefox' do
237
- before do
238
- allow(Howitzer).to receive(:cloud_browser_name) { :firefox }
239
- allow(Howitzer).to receive(:cloud_browser_version) { 8 }
240
- end
241
- it { is_expected.to be_falsey }
242
- end
243
- context 'Howitzer.cloud_browser_name is not specified' do
244
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
245
- it do
246
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
247
- end
248
- end
249
- end
250
- end
251
- end
252
-
253
- describe '#ff_browser?' do
254
- subject { ff_browser? }
255
- before do
256
- allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver }
257
- end
258
- context 'when cloud_driver? is TRUE' do
259
- before { allow(self).to receive(:cloud_driver?) { true } }
260
- context 'Howitzer.cloud_browser_name = :ff' do
261
- before { allow(Howitzer).to receive(:cloud_browser_name) { :ff } }
262
- it { is_expected.to be_truthy }
263
- end
264
- context 'Howitzer.cloud_browser_name = :firefox' do
265
- before { allow(Howitzer).to receive(:cloud_browser_name) { :firefox } }
266
- it { is_expected.to be_truthy }
267
- end
268
- context 'Howitzer.cloud_browser_name = :chrome' do
269
- before { allow(Howitzer).to receive(:cloud_browser_name) { :chrome } }
270
- it { is_expected.to be_falsey }
271
- end
272
- context 'Howitzer.cloud_browser_name is not specified' do
273
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
274
- it do
275
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
276
- end
277
- end
278
- end
279
- context 'when cloud_driver? is FALSE' do
280
- before do
281
- allow(self).to receive(:cloud_driver?) { false }
282
- allow(self).to receive(:selenium_driver?) { selenium_driver }
283
- end
284
- context 'when selenium_driver? is TRUE' do
285
- let(:selenium_driver) { true }
286
- context 'Howitzer.selenium_browser = :ff' do
287
- before { allow(Howitzer).to receive(:selenium_browser) { :ff } }
288
- it { is_expected.to be_truthy }
289
- end
290
- context 'Howitzer.selenium_browser = :firefox' do
291
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
292
- it { is_expected.to be_truthy }
293
- end
294
- context 'Howitzer.selenium_browser = :chrome' do
295
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
296
- it { is_expected.to be_falsey }
297
- end
298
- context 'Howitzer.selenium_browser is not specified' do
299
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
300
- it do
301
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
302
- end
303
- end
304
- end
305
- context 'when selenium_driver? is FALSE' do
306
- it { is_expected.to be_falsey }
307
- end
308
- end
309
- context 'when selenium_driver? is TRUE' do
310
- before { allow(self).to receive(:cloud_driver?) { false } }
311
- before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
312
- context 'when selenium_driver? is TRUE' do
313
- let(:selenium_driver) { true }
314
- context 'Howitzer.selenium_browser = :ff' do
315
- before { allow(Howitzer).to receive(:selenium_browser) { :ff } }
316
- it { is_expected.to be_truthy }
317
- end
318
- context 'Howitzer.selenium_browser = :firefox' do
319
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
320
- it { is_expected.to be_truthy }
321
- end
322
- context 'Howitzer.selenium_browser = :chrome' do
323
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
324
- it { is_expected.to be_falsey }
325
- end
326
- context 'Howitzer.selenium_browser is not specified' do
327
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
328
- it do
329
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
330
- end
331
- end
332
- end
333
- end
334
- context 'when selenium_driver? is FALSE' do
335
- before { allow(self).to receive(:selenium_driver?) { false } }
336
- context 'when cloud_driver? is TRUE' do
337
- before { allow(self).to receive(:cloud_driver?) { true } }
338
- context 'Howitzer.cloud_browser_name = :firefox' do
339
- before do
340
- allow(Howitzer).to receive(:cloud_browser_name) { :firefox }
341
- allow(Howitzer).to receive(:cloud_browser_version) { 8 }
342
- end
343
- it { is_expected.to be_truthy }
344
- end
345
- context 'Howitzer.cloud_browser_name = :ff' do
346
- before do
347
- allow(Howitzer).to receive(:cloud_browser_name) { :ff }
348
- allow(Howitzer).to receive(:cloud_browser_version) { 8 }
349
- end
350
- it { is_expected.to be_truthy }
351
- end
352
- context 'Howitzer.cloud_browser_name = :iexplore' do
353
- before do
354
- allow(Howitzer).to receive(:cloud_browser_name) { :iexplore }
355
- allow(Howitzer).to receive(:cloud_browser_version) { 9 }
356
- end
357
- it { is_expected.to be_falsey }
358
- end
359
- context 'Howitzer.cloud_browser_name is not specified' do
360
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
361
- it do
362
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
363
- end
364
- end
365
- end
366
- context 'when selenium_grid_driver? is TRUE' do
367
- before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }
368
- before { allow(self).to receive(:cloud_driver?) { false } }
369
- context 'when selenium_grid_driver? is TRUE' do
370
- let(:selenium_grid_driver) { true }
371
- context 'Howitzer.selenium_browser = :ff' do
372
- before { allow(Howitzer).to receive(:selenium_browser) { :ff } }
373
- it { is_expected.to be_truthy }
374
- end
375
- context 'Howitzer.selenium_browser = :firefox' do
376
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
377
- it { is_expected.to be_truthy }
378
- end
379
- context 'Howitzer.selenium_browser = :chrome' do
380
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
381
- it { is_expected.to be_falsey }
382
- end
383
- context 'Howitzer.selenium_browser is not specified' do
384
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
385
- it do
386
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
387
- end
388
- end
389
- end
390
- end
391
- context 'when selenium_grid_driver? is FALSE' do
392
- before { allow(self).to receive(:selenium_grid_driver?) { false } }
393
- context 'when cloud_driver? is TRUE' do
394
- before { allow(self).to receive(:cloud_driver?) { true } }
395
- context 'Howitzer.cloud_browser_name = :firefox' do
396
- before do
397
- allow(Howitzer).to receive(:cloud_browser_name) { :firefox }
398
- allow(Howitzer).to receive(:cloud_browser_version) { 8 }
399
- end
400
- it { is_expected.to be_truthy }
401
- end
402
- context 'Howitzer.cloud_browser_name = :ff' do
403
- before do
404
- allow(Howitzer).to receive(:cloud_browser_name) { :ff }
405
- allow(Howitzer).to receive(:cloud_browser_version) { 8 }
406
- end
407
- it { is_expected.to be_truthy }
408
- end
409
- context 'Howitzer.cloud_browser_name = :iexplore' do
410
- before do
411
- allow(Howitzer).to receive(:cloud_browser_name) { :iexplore }
412
- allow(Howitzer).to receive(:cloud_browser_version) { 9 }
413
- end
414
- it { is_expected.to be_falsey }
415
- end
416
- context 'Howitzer.cloud_browser_name is not specified' do
417
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
418
- it do
419
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
420
- end
421
- end
422
- end
423
- end
424
- end
425
- end
426
-
427
- describe '#chrome_browser?' do
428
- subject { chrome_browser? }
429
- before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }
430
- context 'when cloud_driver? is TRUE' do
431
- before { allow(self).to receive(:cloud_driver?) { true } }
432
- context 'Howitzer.cloud_browser_name = :chrome' do
433
- before { allow(Howitzer).to receive(:cloud_browser_name) { :chrome } }
434
- it { is_expected.to be_truthy }
435
- end
436
- context 'Howitzer.cloud_browser_name = :firefox' do
437
- before { allow(Howitzer).to receive(:cloud_browser_name) { :firefox } }
438
- it { is_expected.to be_falsey }
439
- end
440
- context 'Howitzer.cloud_browser_name is not specified' do
441
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
442
- it do
443
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
444
- end
445
- end
446
- end
447
- context 'when selenium_driver? is TRUE' do
448
- before { allow(self).to receive(:cloud_driver?) { false } }
449
- before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
450
- context 'when selenium_driver? is TRUE' do
451
- let(:selenium_driver) { true }
452
- context 'Howitzer.selenium_browser = :chrome' do
453
- before { allow(Howitzer).to receive(:selenium_browser) { :chrome } }
454
- it { is_expected.to be_truthy }
455
- end
456
- context 'Howitzer.selenium_browser = :firefox' do
457
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
458
- it { is_expected.to be_falsey }
459
- end
460
- context 'Howitzer.selenium_browser is not specified' do
461
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
462
- it do
463
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
464
- end
465
- end
466
- end
467
- end
468
- end
469
-
470
- describe '#safari_browser?' do
471
- subject { safari_browser? }
472
- before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }
473
- context 'when cloud_driver? is TRUE' do
474
- before { allow(self).to receive(:cloud_driver?) { true } }
475
- context 'Howitzer.cloud_browser_name = :safari' do
476
- before { allow(Howitzer).to receive(:cloud_browser_name) { :safari } }
477
- it { is_expected.to be_truthy }
478
- end
479
- context 'Howitzer.cloud_browser_name = :firefox' do
480
- before { allow(Howitzer).to receive(:cloud_browser_name) { :firefox } }
481
- it { is_expected.to be_falsey }
482
- end
483
- context 'Howitzer.cloud_browser_name is not specified' do
484
- before { allow(Howitzer).to receive(:cloud_browser_name) { nil } }
485
- it do
486
- expect { subject }.to raise_error(Howitzer::CloudBrowserNotSpecifiedError, 'Please check your settings')
487
- end
488
- end
489
- end
490
- context 'when sauce_driver? is FALSE' do
491
- before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
492
- before { allow(self).to receive(:cloud_driver?) { false } }
493
- context 'when selenium_driver? is TRUE' do
494
- let(:selenium_driver) { true }
495
- context 'Howitzer.selenium_browser = :safari' do
496
- before { allow(Howitzer).to receive(:selenium_browser) { :safari } }
497
- it { is_expected.to be_truthy }
498
- end
499
- context 'Howitzer.selenium_browser = :firefox' do
500
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
501
- it { is_expected.to be_falsey }
502
- end
503
- context 'Howitzer.selenium_browser is not specified' do
504
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
505
- it do
506
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
507
- end
508
- end
509
- end
510
- context 'when selenium_driver? is FALSE' do
511
- it { is_expected.to be_falsey }
512
- end
513
- end
514
- context 'when selenium_driver? is TRUE' do
515
- before { allow(self).to receive(:cloud_driver?) { false } }
516
- before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
517
- context 'when selenium_driver? is TRUE' do
518
- let(:selenium_driver) { true }
519
- context 'Howitzer.selenium_browser = :safari' do
520
- before { allow(Howitzer).to receive(:selenium_browser) { :safari } }
521
- it { is_expected.to be_truthy }
522
- end
523
- context 'Howitzer.selenium_browser = :firefox' do
524
- before { allow(Howitzer).to receive(:selenium_browser) { :firefox } }
525
- it { is_expected.to be_falsey }
526
- end
527
- context 'Howitzer.selenium_browser is not specified' do
528
- before { allow(Howitzer).to receive(:selenium_browser) { nil } }
529
- it do
530
- expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError, 'Please check your settings')
531
- end
532
- end
533
- end
534
- end
535
- end
536
- describe '#duration' do
537
- context 'when more than hour' do
538
- it { expect(duration(10_000)).to eq('[2h 46m 40s]') }
539
- end
540
- context 'when 1 hour exactly' do
541
- it { expect(duration(3600)).to eq('[1h 0m 0s]') }
542
- end
543
- context 'when 0 hours and more than minute' do
544
- it { expect(duration(2000)).to eq('[33m 20s]') }
545
- end
546
- context 'when 1 minute exactly' do
547
- it { expect(duration(60)).to eq('[1m 0s]') }
548
- end
549
- context 'when less than minute' do
550
- it { expect(duration(45)).to eq('[0m 45s]') }
551
- end
552
- context 'when zero' do
553
- it { expect(duration(0)).to eq('[0m 0s]') }
554
- end
555
- end
556
-
557
- describe '.sauce_resource_path' do
558
- subject { sauce_resource_path(kind) }
559
- let(:name) { 'test_name' }
560
- before do
561
- allow(Howitzer).to receive(:cloud_auth_login) { 'vlad' }
562
- allow(Howitzer).to receive(:cloud_auth_pass) { '11111' }
563
- allow(self).to receive(:session_id) { '12341234' }
564
- end
565
- context 'when kind video' do
566
- let(:kind) { :video }
567
- it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/video.flv') }
568
- end
569
- context 'when kind server_log' do
570
- let(:kind) { :server_log }
571
- it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/selenium-server.log') }
572
- end
573
- context 'when unknown kind' do
574
- let(:kind) { :unknown }
575
- it { expect { subject }.to raise_error(ArgumentError, "Unknown 'unknown' kind") }
576
- end
577
- end
578
-
579
- describe '.update_sauce_job_statu' do
580
- subject { update_sauce_job_status }
581
- before do
582
- allow(Howitzer).to receive(:cloud_auth_login) { 'vlad1' }
583
- allow(Howitzer).to receive(:cloud_auth_pass) { '22222' }
584
- allow(self).to receive(:session_id) { '12341234' }
585
- stub_const('RestClient', double)
586
- end
587
-
588
- it do
589
- expect(RestClient).to receive(:put).with(
590
- 'http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234',
591
- '{}',
592
- content_type: :json,
593
- accept: :json
594
- ).once
595
- subject
596
- end
597
- end
598
-
599
- describe '.update_cloud_job_status' do
600
- subject { update_cloud_job_status(status: true) }
601
- context 'when sauce driver' do
602
- before do
603
- allow(Howitzer).to receive(:driver) { 'sauce' }
604
- expect(self).to receive(:update_sauce_job_status).with(status: true) { true }
605
- end
606
- it { is_expected.to eq(true) }
607
- end
608
- context 'when other driver' do
609
- before { allow(Howitzer).to receive(:driver) { 'browserstack' } }
610
- it { is_expected.to eq('[NOT IMPLEMENTED]') }
611
- end
612
- end
613
-
614
- describe '.session_id' do
615
- subject { session_id }
616
- before do
617
- browser = double
618
- current_session = double
619
- driver = double
620
- instance_variable = double
621
- allow(Capybara).to receive(:current_session) { current_session }
622
- allow(current_session).to receive(:driver) { driver }
623
- allow(driver).to receive(:browser) { browser }
624
- allow(browser).to receive(:instance_variable_get).with(:@bridge) { instance_variable }
625
- allow(instance_variable).to receive(:session_id) { 'test' }
626
- end
627
-
628
- it { is_expected.to eql('test') }
629
- end
630
-
631
- describe '.required_cloud_caps' do
632
- subject { required_cloud_caps }
633
- before do
634
- allow(Howitzer).to receive(:cloud_platform) { 'Windows' }
635
- allow(Howitzer).to receive(:cloud_browser_name) { 'Safari' }
636
- allow(Howitzer).to receive(:cloud_browser_version) { '10.0' }
637
- allow(self).to receive(:prefix_name) { 'Suite' }
638
- end
639
- it 'should return correct hash' do
640
- is_expected.to eq(
641
- platform: 'Windows',
642
- browserName: 'Safari',
643
- version: '10.0',
644
- name: 'Suite Safari'
645
- )
646
- end
647
- end
648
-
649
- describe '.remote_file_detector' do
650
- subject { remote_file_detector }
651
- it 'should return lambda' do
652
- is_expected.to be_a(Proc)
653
- end
654
-
655
- it 'should return nil when file missing' do
656
- expect(subject.call('unknown.file')).to be_nil
657
- end
658
- end
659
-
660
- describe '.cloud_driver' do
661
- let(:app) { double(:app) }
662
- let(:caps) { double(:caps) }
663
- let(:url) { 'https://example.com' }
664
- let(:file_detector) { double(:file) }
665
- let(:driver) { double(:driver) }
666
- let(:driver_browser) { double(:driver_browser) }
667
- let(:cap_class) { double(:cap_class) }
668
- let(:des_caps) { double(:des_class) }
669
- let(:http_class) { double(:http_class) }
670
- let(:http_client) { double(:http_client) }
671
- subject { cloud_driver(app, caps, url) }
672
- before do
673
- allow(Howitzer).to receive(:cloud_http_idle_timeout) { 10 }
674
- allow(self).to receive(:remote_file_detector) { file_detector }
675
- stub_const('Selenium::WebDriver::Remote::Capabilities', cap_class)
676
- allow(cap_class).to receive(:new).with(caps) { des_caps }
677
- stub_const('Selenium::WebDriver::Remote::Http::Default', http_class)
678
- allow(http_class).to receive(:new).with(no_args) { http_client }
679
- expect(http_client).to receive(:read_timeout=).with(10)
680
- expect(http_client).to receive(:open_timeout=).with(10)
681
- allow(Capybara::Selenium::Driver).to receive(:new).with(app, kind_of(Hash)) { driver }
682
- expect(driver).to receive(:browser) { driver_browser }
683
- expect(driver_browser).to receive(:file_detector=).with(file_detector)
684
- end
685
- it { is_expected.to eq(driver) }
686
- end
687
-
688
- describe '.cloud_resource_path' do
689
- subject { cloud_resource_path(:video) }
690
- context 'when sauce driver' do
691
- before do
692
- allow(Howitzer).to receive(:driver) { 'sauce' }
693
- expect(self).to receive(:sauce_resource_path).with(:video) { true }
694
- end
695
- it { is_expected.to eq(true) }
696
- end
697
- context 'when other driver' do
698
- before { allow(Howitzer).to receive(:driver) { 'browserstack' } }
699
- it { is_expected.to eq('[NOT IMPLEMENTED]') }
700
- end
701
- end
702
-
703
- describe '.prefix_name' do
704
- subject { prefix_name }
705
- context 'when current rake task present' do
706
- before { Howitzer.current_rake_task = 'Foo' }
707
- after { Howitzer.current_rake_task = nil }
708
- it { is_expected.to eq('FOO') }
709
- end
710
- context 'when rake_task_name empty' do
711
- it { is_expected.to eq('ALL') }
712
- end
713
- end
714
-
715
- describe '.load_driver_gem!' do
716
- subject { load_driver_gem!(:webkit, 'capybara-webkit', 'capybara-webkit') }
717
- context 'when possible to require' do
718
- before { allow(self).to receive(:require).with('capybara-webkit') { true } }
719
- it { expect { subject }.not_to raise_error }
720
- end
721
- context 'when impossible to require' do
722
- it do
723
- expect { subject }.to raise_error(
724
- LoadError,
725
- "`:webkit` driver is unable to load `capybara-webkit`, please add `gem 'capybara-webkit'` to your Gemfile."
726
- )
727
- end
728
- end
729
- end
730
- end