howitzer 2.1.1 → 2.4.0

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