82 lines
2.5 KiB
Ruby
82 lines
2.5 KiB
Ruby
# 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 'Libraries', 'lib'
|
|
end
|
|
|
|
# Configure Rails Environment
|
|
ENV['RAILS_ENV'] = 'test'
|
|
|
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
|
|
|
require 'rspec/rails'
|
|
require 'database_cleaner'
|
|
require 'ffaker'
|
|
|
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
# in spec/support/ and its subdirectories.
|
|
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
|
|
|
# Requires factories defined in spree_core
|
|
require 'spree/testing_support/factories'
|
|
require 'spree/testing_support/controller_requests'
|
|
require 'spree/testing_support/authorization_helpers'
|
|
require 'spree/testing_support/url_helpers'
|
|
|
|
# Requires factories defined in lib/spree_burstnet/factories.rb
|
|
require 'spree_burstnet/factories'
|
|
|
|
RSpec.configure do |config|
|
|
config.include FactoryGirl::Syntax::Methods
|
|
|
|
# == URL Helpers
|
|
#
|
|
# Allows access to Spree's routes in specs:
|
|
#
|
|
# visit spree.admin_path
|
|
# current_path.should eql(spree.products_path)
|
|
config.include Spree::TestingSupport::UrlHelpers
|
|
|
|
# == Mock Framework
|
|
#
|
|
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
#
|
|
# config.mock_with :mocha
|
|
# config.mock_with :flexmock
|
|
# config.mock_with :rr
|
|
config.mock_with :rspec
|
|
config.color = true
|
|
|
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
|
|
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
|
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
|
# to setup a test will be unavailable to the browser, which runs under a seperate server instance.
|
|
config.use_transactional_fixtures = false
|
|
|
|
# Ensure Suite is set to use transactions for speed.
|
|
config.before :suite do
|
|
DatabaseCleaner.strategy = :transaction
|
|
DatabaseCleaner.clean_with :truncation
|
|
end
|
|
|
|
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
|
config.before :each do
|
|
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
|
|
DatabaseCleaner.start
|
|
end
|
|
|
|
# After each spec clean the database.
|
|
config.after :each do
|
|
DatabaseCleaner.clean
|
|
end
|
|
|
|
config.fail_fast = ENV['FAIL_FAST'] || false
|
|
end
|