-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathspec_helper.rb
88 lines (67 loc) · 1.58 KB
/
spec_helper.rb
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
# frozen_string_literal: true
require 'combustion'
Combustion.path = 'spec/dummy'
Combustion.initialize! :active_record, :action_controller
require 'simplecov'
require 'rspec'
require 'rspec/retry'
require 'database_cleaner'
require 'factory_bot'
require 'faker'
require 'pry'
# Start Simplecov
SimpleCov.start do
add_filter 'spec/'
end
# Configure RSpec
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before(:suite) do
FactoryBot.find_definitions
end
config.color = true
config.fail_fast = false
config.order = :random
Kernel.srand config.seed
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before do
DatabaseCleaner.strategy = :transaction
end
config.before do
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
# disable monkey patching
# see: https://relishapp.com/rspec/rspec-core/v/3-8/docs/configuration/zero-monkey-patching-mode
config.disable_monkey_patching!
if ENV.key?('GITHUB_ACTIONS')
config.around do |ex|
ex.run_with_retry retry: 3
end
end
end
class RunningSpec
def self.sqlite?
ENV['DB_ADAPTER'] == 'sqlite3'
end
def self.oracle?
ENV['DB_ADAPTER'] == 'oracle_enhanced'
end
def self.mysql?
ENV['DB_ADAPTER'] == 'mysql2'
end
def self.postgresql?
ENV['DB_ADAPTER'] == 'postgresql'
end
end
# Require our gem
require 'ajax-datatables-rails'
# Load test helpers
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].sort.each { |f| require f }