This is the first post of qiita. I read everyday-rails and want to write a test using RSpec from now on, so I decided to write it as a memorandum. If you have any questions, I would appreciate it if you could point them out in the comments.
Add the following to bundle intall
Gemfile
group :development, :test do
gem 'rspec-rails'
# Factory_When using a bot
gem 'factory_bot_rails'
end
group :development do
gem 'spring-commands-rspec'
end
$ rails g rspec:install
Execute the above command and add the following to the created .rspec. Adding this flag makes the spec output easier to read (there are other --warnings flags, etc.)
.rspec
--format documentation
Then execute the following command. bin/rspec is created.
$ bundle exec spring binstub rspec
Set Rails to have a spec file for RSpec created with you when you add code to your application using the rails generate command. Set false if you don't want it to be created automatically. (If you don't want to create controller specs, controller_specs: false)
config/application.rb
class Application < Rails::Application
config.generators do |g|
g.test_framework :rspec,
view_specs: false,
helper_specs: false,
routing_specs: false
end
end
Recommended Posts