BigW Consortium Gitlab

spec_helper.rb 1.54 KB
Newer Older
1 2
require './spec/simplecov_env'
SimpleCovEnv.start!
3

4
ENV["RAILS_ENV"] ||= 'test'
5

6
require File.expand_path("../../config/environment", __FILE__)
Robert Speicher committed
7
require 'rspec/rails'
8
require 'shoulda/matchers'
Robert Speicher committed
9
require 'sidekiq/testing/inline'
Kamil Trzcinski committed
10
require 'rspec/retry'
Kamil Trzcinski committed
11

12 13 14 15
if ENV['CI']
  require 'knapsack'
  Knapsack::Adapters::RSpecAdapter.bind
end
Robert Speicher committed
16 17 18

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
19
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
Robert Speicher committed
20 21

RSpec.configure do |config|
Jeroen van Baarsen committed
22 23
  config.use_transactional_fixtures = false
  config.use_instantiated_fixtures  = false
Robert Speicher committed
24 25
  config.mock_with :rspec

Kamil Trzcinski committed
26 27 28
  config.verbose_retry = true
  config.display_try_failure_messages = true

Robert Speicher committed
29
  config.include Devise::TestHelpers, type: :controller
30 31
  config.include LoginHelpers,        type: :feature
  config.include LoginHelpers,        type: :request
32
  config.include StubConfiguration
33
  config.include EmailHelpers
Robert Speicher committed
34
  config.include TestEnv
35
  config.include ActiveJob::TestHelper
36 37
  config.include StubGitlabCalls
  config.include StubGitlabData
38

39
  config.infer_spec_type_from_file_location!
40
  config.raise_errors_for_deprecations!
Robert Speicher committed
41 42

  config.before(:suite) do
43
    TestEnv.init
Robert Speicher committed
44
  end
45 46 47 48 49 50 51

  config.around(:each, :caching) do |example|
    caching_store = Rails.cache
    Rails.cache = ActiveSupport::Cache::MemoryStore.new if example.metadata[:caching]
    example.run
    Rails.cache = caching_store
  end
Andrew8xx8 committed
52
end
53

Kamil Trzcinski committed
54 55 56 57
FactoryGirl::SyntaxRunner.class_eval do
  include RSpec::Mocks::ExampleMethods
end

58
ActiveRecord::Migration.maintain_test_schema!