master
1# This file is copied to spec/ when you run 'rails generate rspec:install'
2ENV["RAILS_ENV"] ||= 'test'
3require 'simplecov'
4SimpleCov.start 'rails' do
5 add_filter '/spec/'
6 add_filter '/config/'
7 add_filter '/vendor/'
8end
9require 'spec_helper'
10require File.expand_path("../../config/environment", __FILE__)
11require 'rspec/rails'
12require 'capybara/poltergeist'
13require "factory_girl_rails"
14
15# Requires supporting ruby files with custom matchers and macros, etc, in
16# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
17# run as spec files by default. This means that files in spec/support that end
18# in _spec.rb will both be required and run as specs, causing the specs to be
19# run twice. It is recommended that you do not name files matching this glob to
20# end with _spec.rb. You can configure this pattern with with the --pattern
21# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
22Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
23
24# Checks for pending migrations before tests are run.
25# If you are not using ActiveRecord, you can remove this line.
26ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
27Capybara.javascript_driver = :poltergeist
28
29RSpec.configure do |config|
30 # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31 config.fixture_path = "#{::Rails.root}/spec/fixtures"
32
33 # If you're not using ActiveRecord, or you'd prefer not to run each of your
34 # examples within a transaction, remove the following line or assign false
35 # instead of true.
36 config.use_transactional_fixtures = false
37
38 # RSpec Rails can automatically mix in different behaviours to your tests
39 # based on their file location, for example enabling you to call `get` and
40 # `post` in specs under `spec/controllers`.
41 #
42 # You can disable this behaviour by removing the line below, and instead
43 # explicitly tag your specs with their type, e.g.:
44 #
45 # RSpec.describe UsersController, :type => :controller do
46 # # ...
47 # end
48 #
49 # The different available types are documented in the features, such as in
50 # https://relishapp.com/rspec/rspec-rails/docs
51 config.infer_spec_type_from_file_location!
52 config.include Authentication, type: :controller
53 config.include Authentication::Capybara, type: :feature
54 config.include WaitForAjax, type: :feature
55 config.include FactoryGirl::Syntax::Methods
56
57 config.before(:suite) do
58 DatabaseCleaner.clean_with(:truncation)
59 end
60 config.before(:each) do
61 DatabaseCleaner.strategy = :transaction
62 end
63 config.before(:each, js: true) do
64 DatabaseCleaner.strategy = :truncation
65 end
66 #config.before(:each, :js => true) do
67 #DatabaseCleaner.strategy = :truncation
68 #end
69 config.before(:each) do
70 DatabaseCleaner.start
71 end
72 config.after(:each) do
73 DatabaseCleaner.clean
74 end
75end