spec_helper.rb 1.36 KB
Newer Older
1 2 3 4
unless ENV['CI']
  require 'simplecov'
  SimpleCov.start 'rails'
end
gitlabhq's avatar
gitlabhq committed
5 6 7 8 9 10 11

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/rspec'
12
require 'webmock/rspec'
13
require 'email_spec'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14
require 'headless'
gitlabhq's avatar
gitlabhq committed
15 16 17 18 19

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

20 21 22
# Use capybara-webkit
Capybara.javascript_driver = :webkit

23 24
WebMock.disable_net_connect!(allow_localhost: true)

gitlabhq's avatar
gitlabhq committed
25 26 27
RSpec.configure do |config|
  config.mock_with :rspec

28
  config.include LoginHelpers, type: :request
29
  config.include GitoliteStub
30
  config.include FactoryGirl::Syntax::Methods
31
  config.include Devise::TestHelpers, type: :controller
gitlabhq's avatar
gitlabhq committed
32 33 34 35 36 37

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = false

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
38 39 40 41 42
  config.before :all do
    headless = Headless.new
    headless.start
  end

gitlabhq's avatar
gitlabhq committed
43
  config.before do
44 45
    stub_gitolite!

46
    # !!! Observers disabled by default in tests
47 48
    ActiveRecord::Base.observers.disable(:all)
    # ActiveRecord::Base.observers.enable(:all)
gitlabhq's avatar
gitlabhq committed
49 50
  end
end