Skip to content

Instantly share code, notes, and snippets.

@stabenfeldt
Created January 23, 2016 20:18
Show Gist options
  • Save stabenfeldt/453c3f0f8162f6f1fc2d to your computer and use it in GitHub Desktop.
Save stabenfeldt/453c3f0f8162f6f1fc2d to your computer and use it in GitHub Desktop.
if ENV["COVERAGE"]
# Run Coverage report
require 'simplecov'
SimpleCov.start do
add_group 'Controllers', 'app/controllers'
add_group 'Helpers', 'app/helpers'
add_group 'Mailers', 'app/mailers'
add_group 'Models', 'app/models'
add_group 'Views', 'app/views'
add_group 'Jobs', 'app/jobs'
add_group 'Libraries', 'lib'
end
end
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
begin
require File.expand_path("../../config/environment", __FILE__)
rescue LoadError
$stderr.puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
exit 1
end
require 'rspec/rails'
require 'database_cleaner'
require 'ffaker'
Dir["./support/**/*.rb"].sort.each { |f| require f }
if ENV["CHECK_TRANSLATIONS"]
require "spree/testing_support/i18n"
end
require 'spree/testing_support/factories'
require 'spree/testing_support/preferences'
require 'cancan/matchers'
RSpec.configure do |config|
config.color = true
config.infer_spec_type_from_file_location!
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.mock_with :rspec do |c|
c.syntax = :expect
end
config.fixture_path = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures")
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, comment the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
config.before :suite do
DatabaseCleaner.clean_with :truncation
end
config.before :each do
Rails.cache.clear
reset_spree_preferences
end
config.include FactoryGirl::Syntax::Methods
config.include Spree::TestingSupport::Preferences
config.extend WithModel
config.fail_fast = ENV['FAIL_FAST'] || false
config.filter_run focus: true
config.run_all_when_everything_filtered = true
config.example_status_persistence_file_path = "./spec/examples.txt"
config.order = :random
Kernel.srand config.seed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment