spec_helper.rb 1.48 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's avatar
Robert Speicher committed
14
require 'rspec/rails'
15
require 'shoulda/matchers'
Robert Speicher's avatar
Robert Speicher committed
16
require 'sidekiq/testing/inline'
Kamil Trzcinski's avatar
Kamil Trzcinski committed
17
require 'rspec/retry'
Kamil Trzcinski's avatar
Kamil Trzcinski committed
18 19 20 21
require 'knapsack'
require_relative 'knapsack_merger'

Knapsack::Adapters::RSpecAdapter.bind
Robert Speicher's avatar
Robert Speicher committed
22 23 24

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

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

Kamil Trzcinski's avatar
Kamil Trzcinski committed
32 33 34
  config.verbose_retry = true
  config.display_try_failure_messages = true

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

46
  config.infer_spec_type_from_file_location!
47
  config.raise_errors_for_deprecations!
Robert Speicher's avatar
Robert Speicher committed
48 49

  config.before(:suite) do
50
    TestEnv.init
Robert Speicher's avatar
Robert Speicher committed
51
  end
Andrew8xx8's avatar
Andrew8xx8 committed
52
end
53

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

58
ActiveRecord::Migration.maintain_test_schema!