Generate a new project without the included testing and with a postgres database:
rails new MyApp --skip-turbolinks --skip-spring -T --database=postgresqlAdd VCR
group :test do
gem 'vcr'
gem 'webmock'
endAdd to spec_helper.rb
require 'vcr'
VCR.configure do |config|
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
config.hook_into :webmock
endInclude as first line in test setup (after describe, context, and it
VCR.use_cassette("#repos") do OR Add to spec_helper.rb
VCR.configure do |config|
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
config.hook_into :webmock
config.configure_rspec_metadata!
endInclude :vcr in it line of test
it "returns repos for a user", :vcr doAdd Simplecov
gem 'simplecov'Add this to spec_helper
if ENV['COVERAGE'] == 'true'
require 'simplecov'
SimpleCov.start
endAdd this to rails_helper
require 'simplecov'
require 'simplecov'
SimpleCov.start do
add_filter "/spec/"
endAdd rspec, capybara, factory_girl, launchy and database cleaner to gemfile:
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
gem 'factory_girl_rails'
gem 'launchy'
gem 'database_cleaner'
endInstall gems and generate rspec files:
bundle
rails g rspec:installCreate directory and folder for factory girl:
mkdir spec/support
touch spec/support/factory_girl.rbAdd Rspec configuration to 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
endUncomment this line from rails_helper.rb
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }