Skip to content

Instantly share code, notes, and snippets.

@osiro
Created November 14, 2014 01:51
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 osiro/054a2f6c56dc3a39c1af to your computer and use it in GitHub Desktop.
Save osiro/054a2f6c56dc3a39c1af to your computer and use it in GitHub Desktop.
ENV["RAILS_ENV"] ||= 'test'
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'pundit/rspec'
require 'capybara/poltergeist'
require 'capybara-screenshot/rspec'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
Capybara.javascript_driver = :poltergeist
# Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run
Capybara::Screenshot.autosave_on_failure = true
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false # Using DB cleaner
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
if example.metadata[:js]
DatabaseCleaner.strategy = :truncation
else
DatabaseCleaner.strategy = :transaction
end
DatabaseCleaner.cleaning { example.run }
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.infer_spec_type_from_file_location!
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
config.include Devise::TestHelpers, type: :controller
config.include FeatureHelper, type: :feature
config.include AdminFeatureHelper, type: :feature
config.extend FeatureMacros, type: :feature
config.extend AuthenticationHelpers, type: :controller
config.extend DescribeHelpers, type: :controller
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment