master
1# This file is copied to spec/ when you run "rails generate rspec:install"
2ENV["RAILS_ENV"] ||= "test"
3require "coveralls"
4Coveralls.wear!("rails")
5require "spec_helper"
6require File.expand_path("../../config/environment", __FILE__)
7require "rspec/rails"
8# Add additional requires below this line. Rails is not loaded until this point!
9require "capybara/poltergeist"
10require "rack_session_access/capybara"
11require "sidekiq/testing"
12
13Sidekiq::Testing.inline!
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 the --pattern
21# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
22#
23# The following line is provided for convenience purposes. It has the downside
24# of increasing the boot-up time by auto-requiring all files in the support
25# directory. Alternatively, in the individual `*_spec.rb` files, manually
26# require only the support files necessary.
27#
28Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
29
30# Checks for pending migrations before tests are run.
31# If you are not using ActiveRecord, you can remove this line.
32ActiveRecord::Migration.maintain_test_schema!
33Capybara.javascript_driver = :poltergeist
34
35RSpec.configure do |config|
36 # Remove this line if you"re not using ActiveRecord or ActiveRecord fixtures
37 config.fixture_path = "#{::Rails.root}/spec/fixtures"
38 config.include FactoryGirl::Syntax::Methods
39 config.include HttpAuthentication
40 config.use_transactional_fixtures = false
41 config.infer_spec_type_from_file_location!
42 config.before(:suite) do
43 DatabaseCleaner.clean_with(:truncation)
44 end
45
46 config.before(:each) do
47 DatabaseCleaner.strategy = :transaction
48 end
49
50 config.before(:each, js: true) do
51 DatabaseCleaner.strategy = :truncation
52 page.driver.browser.url_blacklist = [
53 "https://apis.google.com",
54 "http://fonts.googleapis.com",
55 "https://www.google.com",
56 "https://accounts.google.com",
57 "https://maps.google.com",
58 "https://s.ytimg.com",
59 "https://secure.gravatar.com",
60 "https://www.youtube-nocookie.com",
61 ]
62 end
63
64 config.before(:each) do
65 DatabaseCleaner.start
66 end
67
68 config.after(:each) do
69 DatabaseCleaner.clean
70 end
71
72 config.after(:each) do |example|
73 if example.metadata[:type] == :feature && example.exception.present?
74 subject.record_failure
75 end
76 end
77end