質問編集履歴
1
gemfileとspec_helperの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,353 @@
|
|
25
25
|
ググったのですが、テスト実行完了後にレコードを消したいなどの記事がたくさん出てきたのですが、テストの実行直後にレコード以前にテーブル自体が全て消えてしまう症状が出ている方が見つからず対処法がわからない状態です。
|
26
26
|
|
27
27
|
よろしくお願いします。
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
gemfile
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
source 'https://rubygems.org'
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
44
|
+
|
45
|
+
gem 'rails', '~> 5.1.4'
|
46
|
+
|
47
|
+
# Use mysql as the database for Active Record
|
48
|
+
|
49
|
+
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
50
|
+
|
51
|
+
# Use Puma as the app server
|
52
|
+
|
53
|
+
gem 'puma', '~> 3.7'
|
54
|
+
|
55
|
+
# Use SCSS for stylesheets
|
56
|
+
|
57
|
+
gem 'sass-rails', '~> 5.0'
|
58
|
+
|
59
|
+
# Use Uglifier as compressor for JavaScript assets
|
60
|
+
|
61
|
+
gem 'uglifier', '>= 1.3.0'
|
62
|
+
|
63
|
+
# See https://github.com/rails/execjs#readme for more supported runtimes
|
64
|
+
|
65
|
+
gem 'therubyracer', platforms: :ruby
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
# Use CoffeeScript for .coffee assets and views
|
70
|
+
|
71
|
+
gem 'coffee-rails', '~> 4.2'
|
72
|
+
|
73
|
+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
74
|
+
|
75
|
+
gem 'turbolinks', '~> 5'
|
76
|
+
|
77
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
78
|
+
|
79
|
+
gem 'jbuilder', '~> 2.5'
|
80
|
+
|
81
|
+
# Use Redis adapter to run Action Cable in production
|
82
|
+
|
83
|
+
# gem 'redis', '~> 3.0'
|
84
|
+
|
85
|
+
# Use ActiveModel has_secure_password
|
86
|
+
|
87
|
+
# gem 'bcrypt', '~> 3.1.7'
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# Use Capistrano for deployment
|
92
|
+
|
93
|
+
# gem 'capistrano-rails', group: :development
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
gem 'webpacker', github: 'rails/webpacker'
|
98
|
+
|
99
|
+
gem 'foreman'
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
gem 'slim-rails'
|
104
|
+
|
105
|
+
gem 'html2slim'
|
106
|
+
|
107
|
+
gem 'ridgepole'
|
108
|
+
|
109
|
+
gem 'devise'
|
110
|
+
|
111
|
+
gem "refile", require: "refile/rails", github: 'manfe/refile'
|
112
|
+
|
113
|
+
gem "refile-mini_magick"
|
114
|
+
|
115
|
+
gem "refile-s3", '~> 0.2.0'
|
116
|
+
|
117
|
+
gem 'devise_token_auth'
|
118
|
+
|
119
|
+
gem 'grape'
|
120
|
+
|
121
|
+
gem 'grape-jbuilder'
|
122
|
+
|
123
|
+
gem 'grape_logging'
|
124
|
+
|
125
|
+
gem 'omniauth', '>= 1.0.0'
|
126
|
+
|
127
|
+
gem 'seed-fu'
|
128
|
+
|
129
|
+
gem 'geocoder'
|
130
|
+
|
131
|
+
gem 'rqrcode_png'
|
132
|
+
|
133
|
+
gem 'chunky_png'
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
group :development, :test do
|
138
|
+
|
139
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
140
|
+
|
141
|
+
gem 'capybara', '~> 2.13'
|
142
|
+
|
143
|
+
gem 'selenium-webdriver'
|
144
|
+
|
145
|
+
gem 'pry-rails'
|
146
|
+
|
147
|
+
gem 'rspec-rails', '~> 3.7'
|
148
|
+
|
149
|
+
gem 'factory_bot_rails'
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
group :development do
|
156
|
+
|
157
|
+
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
158
|
+
|
159
|
+
gem 'web-console', '>= 3.3.0'
|
160
|
+
|
161
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
162
|
+
|
163
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
164
|
+
|
165
|
+
gem 'spring'
|
166
|
+
|
167
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
spec_helper
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
186
|
+
|
187
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
188
|
+
|
189
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
190
|
+
|
191
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
192
|
+
|
193
|
+
# files.
|
194
|
+
|
195
|
+
#
|
196
|
+
|
197
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
198
|
+
|
199
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
200
|
+
|
201
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
202
|
+
|
203
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
204
|
+
|
205
|
+
# a separate helper file that requires the additional dependencies and performs
|
206
|
+
|
207
|
+
# the additional setup, and require it from the spec files that actually need
|
208
|
+
|
209
|
+
# it.
|
210
|
+
|
211
|
+
#
|
212
|
+
|
213
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
214
|
+
|
215
|
+
RSpec.configure do |config|
|
216
|
+
|
217
|
+
# rspec-expectations config goes here. You can use an alternate
|
218
|
+
|
219
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
220
|
+
|
221
|
+
# assertions if you prefer.
|
222
|
+
|
223
|
+
config.expect_with :rspec do |expectations|
|
224
|
+
|
225
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
226
|
+
|
227
|
+
# and `failure_message` of custom matchers include text for helper methods
|
228
|
+
|
229
|
+
# defined using `chain`, e.g.:
|
230
|
+
|
231
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
232
|
+
|
233
|
+
# # => "be bigger than 2 and smaller than 4"
|
234
|
+
|
235
|
+
# ...rather than:
|
236
|
+
|
237
|
+
# # => "be bigger than 2"
|
238
|
+
|
239
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
246
|
+
|
247
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
248
|
+
|
249
|
+
config.mock_with :rspec do |mocks|
|
250
|
+
|
251
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
252
|
+
|
253
|
+
# a real object. This is generally recommended, and will default to
|
254
|
+
|
255
|
+
# `true` in RSpec 4.
|
256
|
+
|
257
|
+
mocks.verify_partial_doubles = true
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
264
|
+
|
265
|
+
# have no way to turn it off -- the option exists only for backwards
|
266
|
+
|
267
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
268
|
+
|
269
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
270
|
+
|
271
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
272
|
+
|
273
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
# The settings below are suggested to provide a good initial experience
|
278
|
+
|
279
|
+
# with RSpec, but feel free to customize to your heart's content.
|
280
|
+
|
281
|
+
=begin
|
282
|
+
|
283
|
+
# This allows you to limit a spec run to individual examples or groups
|
284
|
+
|
285
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
286
|
+
|
287
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
288
|
+
|
289
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
290
|
+
|
291
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
292
|
+
|
293
|
+
config.filter_run_when_matching :focus
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
# Allows RSpec to persist some state between runs in order to support
|
298
|
+
|
299
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
300
|
+
|
301
|
+
# you configure your source control system to ignore this file.
|
302
|
+
|
303
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
308
|
+
|
309
|
+
# recommended. For more details, see:
|
310
|
+
|
311
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
312
|
+
|
313
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
314
|
+
|
315
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
316
|
+
|
317
|
+
config.disable_monkey_patching!
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
322
|
+
|
323
|
+
# file, and it's useful to allow more verbose output when running an
|
324
|
+
|
325
|
+
# individual spec file.
|
326
|
+
|
327
|
+
if config.files_to_run.one?
|
328
|
+
|
329
|
+
# Use the documentation formatter for detailed output,
|
330
|
+
|
331
|
+
# unless a formatter has already been configured
|
332
|
+
|
333
|
+
# (e.g. via a command-line flag).
|
334
|
+
|
335
|
+
config.default_formatter = "doc"
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
# Print the 10 slowest examples and example groups at the
|
342
|
+
|
343
|
+
# end of the spec run, to help surface which specs are running
|
344
|
+
|
345
|
+
# particularly slow.
|
346
|
+
|
347
|
+
config.profile_examples = 10
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
# Run specs in random order to surface order dependencies. If you find an
|
352
|
+
|
353
|
+
# order dependency and want to debug it, you can fix the order by providing
|
354
|
+
|
355
|
+
# the seed, which is printed after each run.
|
356
|
+
|
357
|
+
# --seed 1234
|
358
|
+
|
359
|
+
config.order = :random
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
364
|
+
|
365
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
366
|
+
|
367
|
+
# test failures related to randomization by passing the same `--seed` value
|
368
|
+
|
369
|
+
# as the one that triggered the failure.
|
370
|
+
|
371
|
+
Kernel.srand config.seed
|
372
|
+
|
373
|
+
=end
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
```
|