- Remove /test directory, it’s minitest
- Install RSpec gem
# Gemfile
group :development , :test do
gem 'rspec-rails' , '~> 3.4.2'
gem 'factory_girl_rails', '~> 4.7.0'
gem 'capybara', '~> 2.0.7'
end
group :test do
gem 'database_cleaner'
end
$ bundle install
$ rails generate rspec:install
- Config factory girl
#spec/support/factory_girl.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
end
end
- Load factory to rspec
# Uncommentme! in rails_helper
Dir [Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
- Load Capybara to rspec
# rails_helper
require 'capybara/rails'