質問編集履歴

1

gem,helperの設定情報を追記しました。

2019/08/01 03:22

投稿

ShunichiroGenei
ShunichiroGenei

スコア19

test CHANGED
File without changes
test CHANGED
@@ -28,12 +28,316 @@
28
28
 
29
29
 
30
30
 
31
- spec_helper.rb
31
+ テスト結果
32
-
32
+
33
- ```
33
+ ```
34
+
35
+ 2019-08-01 10:35:03 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead.
36
+
37
+ 2019-08-01 10:35:04 WARN Selenium [DEPRECATION] :args or :switches is deprecated. Use Selenium::WebDriver::Chrome::Options#add_argument instead.
38
+
39
+ Capybara starting Puma...
40
+
41
+ * Version 3.12.1 , codename: Llamas in Pajamas
42
+
43
+ * Min threads: 0, max threads: 4
44
+
45
+ * Listening on tcp://127.0.0.1:58568
46
+
47
+ FF
48
+
49
+
50
+
51
+ Failures:
52
+
53
+
54
+
55
+ 1) タスク管理機能 一覧表示機能 ユーザーAがログインしているとき ユーザーAが作成したタスクが表示される
56
+
57
+ Got 0 failures and 3 other errors:
58
+
59
+
60
+
61
+ 1.1) Failure/Error: expect(page).to have_content '最初のタスク'
62
+
63
+
64
+
65
+ Selenium::WebDriver::Error::WebDriverError:
66
+
67
+ chrome not reachable
68
+
69
+ (Session info: headless chrome=76.0.3809.87)
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ # #0 0x7f8065e937a9 <unknown>
78
+
79
+ # ./spec/system/tasks_spec.rb:20:in `block (4 levels) in <top (required)>'
80
+
81
+
82
+
83
+ 1.2) Failure/Error: Unable to infer file and line number from backtrace
84
+
85
+
86
+
87
+ Selenium::WebDriver::Error::WebDriverError:
88
+
89
+ chrome not reachable
90
+
91
+ (Session info: headless chrome=76.0.3809.87)
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ # #0 0x7f8065e937a9 <unknown>
100
+
101
+ # ------------------
102
+
103
+ # --- Caused by: ---
104
+
105
+ # Selenium::WebDriver::Error::WebDriverError:
106
+
107
+ # chrome not reachable
108
+
109
+ # (Session info: headless chrome=76.0.3809.87)
110
+
111
+ # #0 0x7f8065e937a9 <unknown>
112
+
113
+
114
+
115
+ 1.3) Failure/Error: Unable to infer file and line number from backtrace
116
+
117
+
118
+
119
+ Selenium::WebDriver::Error::WebDriverError:
120
+
121
+ chrome not reachable
122
+
123
+ (Session info: headless chrome=76.0.3809.87)
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ # #0 0x7f8065e937a9 <unknown>
132
+
133
+
134
+
135
+ 2) タスク管理機能 一覧表示機能 ユーザーBがログインしているとき ユーザーAが作成したタスクが表示されない
136
+
137
+ Got 0 failures and 3 other errors:
138
+
139
+
140
+
141
+ 2.1) Failure/Error: visit login_path
142
+
143
+
144
+
145
+ Selenium::WebDriver::Error::WebDriverError:
146
+
147
+ chrome not reachable
148
+
149
+ (Session info: headless chrome=76.0.3809.87)
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+ # #0 0x7f8065e937a9 <unknown>
158
+
159
+ # ./spec/system/tasks_spec.rb:10:in `block (3 levels) in <top (required)>'
160
+
161
+
162
+
163
+ 2.2) Failure/Error: Unable to infer file and line number from backtrace
164
+
165
+
166
+
167
+ Selenium::WebDriver::Error::WebDriverError:
168
+
169
+ chrome not reachable
170
+
171
+ (Session info: headless chrome=76.0.3809.87)
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ # #0 0x7f8065e937a9 <unknown>
180
+
181
+ # ------------------
182
+
183
+ # --- Caused by: ---
184
+
185
+ # Selenium::WebDriver::Error::WebDriverError:
186
+
187
+ # chrome not reachable
188
+
189
+ # (Session info: headless chrome=76.0.3809.87)
190
+
191
+ # #0 0x7f8065e937a9 <unknown>
192
+
193
+
194
+
195
+ 2.3) Failure/Error: Unable to infer file and line number from backtrace
196
+
197
+
198
+
199
+ Selenium::WebDriver::Error::WebDriverError:
200
+
201
+ chrome not reachable
202
+
203
+ (Session info: headless chrome=76.0.3809.87)
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ # #0 0x7f8065e937a9 <unknown>
212
+
213
+
214
+
215
+ Finished in 13.95 seconds (files took 3.16 seconds to load)
216
+
217
+ 2 examples, 2 failures
218
+
219
+
220
+
221
+ Failed examples:
222
+
223
+
224
+
225
+ rspec ./spec/system/tasks_spec.rb:19 # タスク管理機能 一覧表示機能 ユーザーAがログインしているとき ユーザーAが作成したタスクが表示される
226
+
227
+ rspec ./spec/system/tasks_spec.rb:27 # タスク管理機能 一覧表示機能 ユーザーBがログインしているとき ユーザーAが作成したタスクが表示されない
228
+
229
+ ```
230
+
231
+
232
+
233
+
234
+
235
+ 追記)
236
+
237
+ ご指摘ありがとうございます。
238
+
239
+ コメントアウトの部分も含めて一旦貼り付けます。
240
+
241
+
242
+
243
+ ### ■テストで使用するgemとバージョン
244
+
245
+ ```
246
+
247
+ group :test do
248
+
249
+ # Adds support for Capybara system testing and selenium driver
250
+
251
+ gem 'capybara', '>= 2.15'
252
+
253
+ gem 'selenium-webdriver' #バージョン3.142.3
254
+
255
+ # Easy installation and use of chromedriver to run system tests with Chrome
256
+
257
+ gem 'webdrivers' #バージョン4.1.2
258
+
259
+ end
260
+
261
+ ```
262
+
263
+
264
+
265
+ ### ■rails_helper.rb
266
+
267
+ ```
268
+
269
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
270
+
271
+ require 'spec_helper'
272
+
273
+ ENV['RAILS_ENV'] ||= 'test'
274
+
275
+ require File.expand_path('../../config/environment', __FILE__)
276
+
277
+ # Prevent database truncation if the environment is production
278
+
279
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
280
+
281
+ require 'rspec/rails'
282
+
283
+ begin
284
+
285
+ ActiveRecord::Migration.maintain_test_schema!
286
+
287
+ rescue ActiveRecord::PendingMigrationError => e
288
+
289
+ puts e.to_s.strip
290
+
291
+ exit 1
292
+
293
+ end
34
294
 
35
295
  RSpec.configure do |config|
36
296
 
297
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
298
+
299
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
300
+
301
+
302
+
303
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
304
+
305
+ # examples within a transaction, remove the following line or assign false
306
+
307
+ # instead of true.
308
+
309
+ config.use_transactional_fixtures = true
310
+
311
+
312
+
313
+ config.infer_spec_type_from_file_location!
314
+
315
+
316
+
317
+ # Filter lines from Rails gems in backtraces.
318
+
319
+ config.filter_rails_from_backtrace!
320
+
321
+ # arbitrary gems may also be filtered via:
322
+
323
+ # config.filter_gems_from_backtrace("gem name")
324
+
325
+ end
326
+
327
+ ```
328
+
329
+
330
+
331
+ ### ■spec_helper.rb
332
+
333
+ ```
334
+
335
+ require 'capybara/rspec'
336
+
337
+
338
+
339
+ RSpec.configure do |config|
340
+
37
341
  config.before(:each, type: :system) do
38
342
 
39
343
  driven_by :selenium, using: :headless_chrome, screen_size: [1280, 800], options: { args: ["headless", "disable-gpu", "no-sandbox", "disable-dev-shm-usage"] }
@@ -42,248 +346,164 @@
42
346
 
43
347
 
44
348
 
45
- ```
46
-
47
-
48
-
49
- ■テスト結果
50
-
51
- ```
52
-
53
- 2019-08-01 10:35:03 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead.
54
-
55
- 2019-08-01 10:35:04 WARN Selenium [DEPRECATION] :args or :switches is deprecated. Use Selenium::WebDriver::Chrome::Options#add_argument instead.
56
-
57
- Capybara starting Puma...
58
-
59
- * Version 3.12.1 , codename: Llamas in Pajamas
60
-
61
- * Min threads: 0, max threads: 4
62
-
63
- * Listening on tcp://127.0.0.1:58568
64
-
65
- FF
66
-
67
-
68
-
69
- Failures:
70
-
71
-
72
-
73
- 1) タスク管理機能 一覧表示機能 ユーザーAがログインしているとき ユーザーAが作成したタスクが表示される
74
-
75
- Got 0 failures and 3 other errors:
76
-
77
-
78
-
79
- 1.1) Failure/Error: expect(page).to have_content '最初のタスク'
80
-
81
-
82
-
83
- Selenium::WebDriver::Error::WebDriverError:
84
-
85
- chrome not reachable
86
-
87
- (Session info: headless chrome=76.0.3809.87)
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- # #0 0x7f8065e937a9 <unknown>
96
-
97
- # ./spec/system/tasks_spec.rb:20:in `block (4 levels) in <top (required)>'
98
-
99
-
100
-
101
- 1.2) Failure/Error: Unable to infer file and line number from backtrace
102
-
103
-
104
-
105
- Selenium::WebDriver::Error::WebDriverError:
106
-
107
- chrome not reachable
108
-
109
- (Session info: headless chrome=76.0.3809.87)
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
- # #0 0x7f8065e937a9 <unknown>
118
-
119
- # ------------------
120
-
121
- # --- Caused by: ---
122
-
123
- # Selenium::WebDriver::Error::WebDriverError:
124
-
125
- # chrome not reachable
126
-
127
- # (Session info: headless chrome=76.0.3809.87)
128
-
129
- # #0 0x7f8065e937a9 <unknown>
130
-
131
-
132
-
133
- 1.3) Failure/Error: Unable to infer file and line number from backtrace
134
-
135
-
136
-
137
- Selenium::WebDriver::Error::WebDriverError:
138
-
139
- chrome not reachable
140
-
141
- (Session info: headless chrome=76.0.3809.87)
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
- # #0 0x7f8065e937a9 <unknown>
150
-
151
-
152
-
153
- 2) タスク管理機能 一覧表示機能 ユーザーBがログインしているとき ユーザーAが作成したタスクが表示されない
154
-
155
- Got 0 failures and 3 other errors:
156
-
157
-
158
-
159
- 2.1) Failure/Error: visit login_path
160
-
161
-
162
-
163
- Selenium::WebDriver::Error::WebDriverError:
164
-
165
- chrome not reachable
166
-
167
- (Session info: headless chrome=76.0.3809.87)
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
- # #0 0x7f8065e937a9 <unknown>
176
-
177
- # ./spec/system/tasks_spec.rb:10:in `block (3 levels) in <top (required)>'
178
-
179
-
180
-
181
- 2.2) Failure/Error: Unable to infer file and line number from backtrace
182
-
183
-
184
-
185
- Selenium::WebDriver::Error::WebDriverError:
186
-
187
- chrome not reachable
188
-
189
- (Session info: headless chrome=76.0.3809.87)
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
- # #0 0x7f8065e937a9 <unknown>
198
-
199
- # ------------------
200
-
201
- # --- Caused by: ---
202
-
203
- # Selenium::WebDriver::Error::WebDriverError:
204
-
205
- # chrome not reachable
206
-
207
- # (Session info: headless chrome=76.0.3809.87)
208
-
209
- # #0 0x7f8065e937a9 <unknown>
210
-
211
-
212
-
213
- 2.3) Failure/Error: Unable to infer file and line number from backtrace
214
-
215
-
216
-
217
- Selenium::WebDriver::Error::WebDriverError:
218
-
219
- chrome not reachable
220
-
221
- (Session info: headless chrome=76.0.3809.87)
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
- # #0 0x7f8065e937a9 <unknown>
230
-
231
-
232
-
233
- Finished in 13.95 seconds (files took 3.16 seconds to load)
234
-
235
- 2 examples, 2 failures
236
-
237
-
238
-
239
- Failed examples:
240
-
241
-
242
-
243
- rspec ./spec/system/tasks_spec.rb:19 # タスク管理機能 一覧表示機能 ユーザーAがログインしているとき ユーザーAが作成したタスクが表示される
244
-
245
- rspec ./spec/system/tasks_spec.rb:27 # タスク管理機能 一覧表示機能 ユーザーBがログインしているとき ユーザーAが作成したタスクが表示されない```
246
-
247
-
248
-
249
- ### 発生している問題・エラーメッセージ
250
-
251
-
252
-
253
- ```
254
-
255
- エラーメッセージ
256
-
257
- ```
258
-
259
-
260
-
261
- ### 該当のソースコード
262
-
263
-
264
-
265
- ```ここに言語名を入力
266
-
267
- ソースコード
268
-
269
- ```
270
-
271
-
272
-
273
- ### 試したこと
274
-
275
-
276
-
277
- ここに問題に対して試したことを記載してください。
278
-
279
-
280
-
281
- ### 補足情報(FW/ツールのバージョンなど)
282
-
283
-
284
-
285
- ここにより詳細な情報を記載してください。```ここに言語を入力
286
-
287
- コード
288
-
289
- ```
349
+ # rspec-expectations config goes here. You can use an alternate
350
+
351
+ # assertion/expectation library such as wrong or the stdlib/minitest
352
+
353
+ # assertions if you prefer.
354
+
355
+ config.expect_with :rspec do |expectations|
356
+
357
+ # This option will default to `true` in RSpec 4. It makes the `description`
358
+
359
+ # and `failure_message` of custom matchers include text for helper methods
360
+
361
+ # defined using `chain`, e.g.:
362
+
363
+ # be_bigger_than(2).and_smaller_than(4).description
364
+
365
+ # # => "be bigger than 2 and smaller than 4"
366
+
367
+ # ...rather than:
368
+
369
+ # # => "be bigger than 2"
370
+
371
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
372
+
373
+ end
374
+
375
+
376
+
377
+ # rspec-mocks config goes here. You can use an alternate test double
378
+
379
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
380
+
381
+ config.mock_with :rspec do |mocks|
382
+
383
+ # Prevents you from mocking or stubbing a method that does not exist on
384
+
385
+ # a real object. This is generally recommended, and will default to
386
+
387
+ # `true` in RSpec 4.
388
+
389
+ mocks.verify_partial_doubles = true
390
+
391
+ end
392
+
393
+
394
+
395
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
396
+
397
+ # have no way to turn it off -- the option exists only for backwards
398
+
399
+ # compatibility in RSpec 3). It causes shared context metadata to be
400
+
401
+ # inherited by the metadata hash of host groups and examples, rather than
402
+
403
+ # triggering implicit auto-inclusion in groups with matching metadata.
404
+
405
+ config.shared_context_metadata_behavior = :apply_to_host_groups
406
+
407
+
408
+
409
+ # The settings below are suggested to provide a good initial experience
410
+
411
+ # with RSpec, but feel free to customize to your heart's content.
412
+
413
+ =begin
414
+
415
+ # This allows you to limit a spec run to individual examples or groups
416
+
417
+ # you care about by tagging them with `:focus` metadata. When nothing
418
+
419
+ # is tagged with `:focus`, all examples get run. RSpec also provides
420
+
421
+ # aliases for `it`, `describe`, and `context` that include `:focus`
422
+
423
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
424
+
425
+ config.filter_run_when_matching :focus
426
+
427
+
428
+
429
+ # Allows RSpec to persist some state between runs in order to support
430
+
431
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
432
+
433
+ # you configure your source control system to ignore this file.
434
+
435
+ config.example_status_persistence_file_path = "spec/examples.txt"
436
+
437
+
438
+
439
+ # Limits the available syntax to the non-monkey patched syntax that is
440
+
441
+ # recommended. For more details, see:
442
+
443
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
444
+
445
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
446
+
447
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
448
+
449
+ config.disable_monkey_patching!
450
+
451
+
452
+
453
+ # Many RSpec users commonly either run the entire suite or an individual
454
+
455
+ # file, and it's useful to allow more verbose output when running an
456
+
457
+ # individual spec file.
458
+
459
+ if config.files_to_run.one?
460
+
461
+ # Use the documentation formatter for detailed output,
462
+
463
+ # unless a formatter has already been configured
464
+
465
+ # (e.g. via a command-line flag).
466
+
467
+ config.default_formatter = "doc"
468
+
469
+ end
470
+
471
+
472
+
473
+ # Print the 10 slowest examples and example groups at the
474
+
475
+ # end of the spec run, to help surface which specs are running
476
+
477
+ # particularly slow.
478
+
479
+ config.profile_examples = 10
480
+
481
+
482
+
483
+ # Run specs in random order to surface order dependencies. If you find an
484
+
485
+ # order dependency and want to debug it, you can fix the order by providing
486
+
487
+ # the seed, which is printed after each run.
488
+
489
+ # --seed 1234
490
+
491
+ config.order = :random
492
+
493
+
494
+
495
+ # Seed global randomization in this process using the `--seed` CLI option.
496
+
497
+ # Setting this allows you to use `--seed` to deterministically reproduce
498
+
499
+ # test failures related to randomization by passing the same `--seed` value
500
+
501
+ # as the one that triggered the failure.
502
+
503
+ Kernel.srand config.seed
504
+
505
+ =end
506
+
507
+ end
508
+
509
+ ```