Skip to content

Instantly share code, notes, and snippets.

@tuffs
Created June 3, 2018 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuffs/15042f11938f1bdd7ed00970660645dc to your computer and use it in GitHub Desktop.
Save tuffs/15042f11938f1bdd7ed00970660645dc to your computer and use it in GitHub Desktop.
RSpec with Capybara rails_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require 'capybara/rails'
#WARDEN SETUP
# include Warden::Test::Helpers
# Warden.test_mode!
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = false
config.before(:suite) { DatabaseCleaner.clean_with(:truncation) }
config.before(:each) { DatabaseCleaner.strategy = :transaction }
config.before(:each, :js => true) { DatabaseCleaner.strategy = :truncation }
config.before(:each) { DatabaseCleaner.start }
config.after(:each) { DatabaseCleaner.clean }
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
#WARDEN CONFIG
# config.include Warden::Test::Helpers
# config.include FactoryBot::Syntax::Methods
end
@tuffs
Copy link
Author

tuffs commented Mar 25, 2019

Uncomment the two lines after #WARDEN CONFIG lines to bring in Warden and FactoryBot helper methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment