BigW Consortium Gitlab

spec_helper.rb 1.6 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'
Robert Speicher committed
18 19 20

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

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

Kamil Trzcinski committed
28 29 30
  config.verbose_retry = true
  config.display_try_failure_messages = true

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

42
  config.infer_spec_type_from_file_location!
43
  config.raise_errors_for_deprecations!
Robert Speicher committed
44 45

  config.before(:suite) do
46
    TestEnv.init
Robert Speicher committed
47
  end
Andrew8xx8 committed
48
end
49

Kamil Trzcinski committed
50 51 52 53
FactoryGirl::SyntaxRunner.class_eval do
  include RSpec::Mocks::ExampleMethods
end

54 55 56 57 58 59
# Work around a Rails 4.2.5.1 issue
# See https://github.com/rspec/rspec-rails/issues/1532
RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator.class_eval do
  alias_method :find_all_anywhere, :find_all
end

60
ActiveRecord::Migration.maintain_test_schema!