-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy pathspec_helper.rb
More file actions
100 lines (80 loc) · 2.43 KB
/
Copy pathspec_helper.rb
File metadata and controls
100 lines (80 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
begin
require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
SimpleCov::Formatter::HTMLFormatter
)
SimpleCov.start do
add_filter '/spec/'
end
rescue LoadError
# Skip loading
end
require 'rubygems'
ENV['RAILS_ENV'] = ENV['RACK_ENV'] = 'test'
require File.expand_path('../dummyapp/config/environment', __FILE__)
require 'rspec/rails'
require 'database_cleaner'
# Needed for rollbar-rails-runner (or anything else that doesn't have Rails.root)
ENV['DUMMYAPP_PATH'] = "#{File.dirname(__FILE__)}/dummyapp"
begin
require 'webmock/rspec'
WebMock.disable_net_connect!(:allow => 'codeclimate.com')
rescue LoadError
# Skip loading
end
namespace :dummy do
load 'spec/dummyapp/Rakefile'
end
if ENV['TRAVIS_JDK_VERSION'] == 'oraclejdk7'
require 'rollbar/configuration'
Rollbar::Configuration::DEFAULT_ENDPOINT = 'https://api-alt.rollbar.com/api/1/item/'.freeze
end
if Gem::Version.new(Rails.version) < Gem::Version.new('5.0')
Rake::Task['dummy:db:setup'].invoke
else
Rake::Task['dummy:db:test:prepare'].invoke
end
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
RSpec.configure do |config|
config.extend(Helpers)
config.include(NotifierHelpers)
config.include(FixtureHelpers)
config.include(EncodingHelpers)
config.color = true
config.formatter = 'documentation'
config.use_transactional_fixtures = true
config.order = 'random'
config.expect_with(:rspec) do |c|
c.syntax = [:should, :expect]
end
config.mock_with :rspec do |mocks|
mocks.syntax = [:should, :expect]
end
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
DatabaseCleaner.clean
Rollbar.clear_notifier!
stub_request(:any, /api.rollbar.com/).to_rack(RollbarAPI.new) if defined?(WebMock)
if defined?(WebMock)
stub_request(:post,
%r{api.rollbar.com/api/[0-9]/deploy/$})
.to_rack(DeployAPI::Report.new)
end
if defined?(WebMock)
stub_request(:patch,
%r{api.rollbar.com/api/[0-9]/deploy/[0-9]+})
.to_rack(DeployAPI::Update.new)
end
end
config.after do
DatabaseCleaner.clean
end
if config.respond_to?(:infer_spec_type_from_file_location!)
config.infer_spec_type_from_file_location!
end
config.backtrace_exclusion_patterns = [%r{gems/rspec-.*}]
config.include RSpecCommand if defined?(RSpecCommand)
end