BigW Consortium Gitlab

spec_helper.rb 1.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
if ENV['SIMPLECOV']
  require 'simplecov'
  SimpleCov.start :rails
end

if ENV['COVERALLS']
  require 'coveralls'
  Coveralls.wear_merged!
end

11
ENV["RAILS_ENV"] ||= 'test'
12

13
require File.expand_path("../../config/environment", __FILE__)
Robert Speicher committed
14
require 'rspec/rails'
15
require 'shoulda/matchers'
Robert Speicher committed
16
require 'sidekiq/testing/inline'
Kamil Trzcinski committed
17
require 'rspec/retry'
Kamil Trzcinski committed
18

19 20 21 22
if ENV['CI']
  require 'knapsack'
  Knapsack::Adapters::RSpecAdapter.bind
end
Robert Speicher committed
23 24 25

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

RSpec.configure do |config|
Jeroen van Baarsen committed
29 30
  config.use_transactional_fixtures = false
  config.use_instantiated_fixtures  = false
Robert Speicher committed
31 32
  config.mock_with :rspec

Kamil Trzcinski committed
33 34 35
  config.verbose_retry = true
  config.display_try_failure_messages = true

Robert Speicher committed
36
  config.include Devise::TestHelpers, type: :controller
37 38
  config.include LoginHelpers,        type: :feature
  config.include LoginHelpers,        type: :request
39
  config.include StubConfiguration
40
  config.include EmailHelpers
41
  config.include RelativeUrl,         type: feature
Robert Speicher committed
42
  config.include TestEnv
43
  config.include ActiveJob::TestHelper
44 45
  config.include StubGitlabCalls
  config.include StubGitlabData
46

47
  config.infer_spec_type_from_file_location!
48
  config.raise_errors_for_deprecations!
Robert Speicher committed
49 50

  config.before(:suite) do
51
    TestEnv.init
Robert Speicher committed
52
  end
Andrew8xx8 committed
53
end
54

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

59
ActiveRecord::Migration.maintain_test_schema!