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 '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("../dummy/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' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} require 'database_cleaner' require 'ffaker' require 'spree/testing_support/authorization_helpers' require 'spree/testing_support/factories' require 'spree/testing_support/preferences' require 'spree/testing_support/controller_requests' require 'spree/testing_support/flash' require 'spree/testing_support/url_helpers' require 'spree/testing_support/order_walkthrough' require 'spree/testing_support/capybara_ext' require 'paperclip/matchers' require 'capybara-screenshot/rspec' Capybara.save_and_open_page_path = ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS'] require 'capybara/poltergeist' Capybara.javascript_driver = :poltergeist 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 # 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 = false config.before :suite do DatabaseCleaner.clean_with :truncation end config.before(:each) do Rails.cache.clear reset_spree_preferences WebMock.disable! if RSpec.current_example.metadata[:js] page.driver.browser.url_blacklist = ['http://fonts.googleapis.com'] DatabaseCleaner.strategy = :truncation else DatabaseCleaner.strategy = :transaction end DatabaseCleaner.start end config.after(:each) do # Ensure js requests finish processing before advancing to the next test wait_for_ajax if RSpec.current_example.metadata[:js] DatabaseCleaner.clean end config.include BaseFeatureHelper, :type => :feature config.after(:each, :type => :feature) do |example| missing_translations = page.body.scan(/translation missing: #{I18n.locale}\.(.*?)[\s<\"&]/) if missing_translations.any? puts "Found missing translations: #{missing_translations.inspect}" puts "In spec: #{example.location}" end end config.include FactoryGirl::Syntax::Methods config.include Spree::TestingSupport::Preferences config.include Spree::TestingSupport::UrlHelpers config.include Spree::TestingSupport::ControllerRequests, type: :controller config.include Spree::TestingSupport::Flash config.include Paperclip::Shoulda::Matchers config.extend WithModel config.fail_fast = ENV['FAIL_FAST'] || false config.example_status_persistence_file_path = "./spec/examples.txt" config.order = :random Kernel.srand config.seed end