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