LoginSignup
1
0

More than 3 years have passed since last update.

個人開発の買付代行サービスにRspecとFactoryBotを導入した

Last updated at Posted at 2021-01-14

参考

https://qiita.com/Ushinji/items/522ed01c9c14b680222c
https://qiita.com/key_it6/items/fb94f229e9e45270c515

やったこと

Gemfile
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

  gem 'factory_bot_rails' #追加
  gem 'rspec-rails' #追加
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'web-console', '>= 3.3.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-commands-rspec' #追加
  gem 'spring-watcher-listen', '~> 2.0.0'
end
Terminal
bundle

bin/rails generate rspec:install
spec/rails_helper.rb
省略
Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f }
省略
spec/support/factory_bot.rb
RSpec.configure do |config|
  config.include FactoryBot::Syntax::Methods
end

結果

Terminal
-> % bin/rspec
Running via Spring preloader in process 32344
No examples found.


Finished in 0.00101 seconds (files took 0.49014 seconds to load)
0 examples, 0 failures
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0