-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathspec_helper.rb
82 lines (67 loc) · 2.72 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
require "bundler/setup"
require "debug" if RUBY_VERSION.to_f >= 2.6 && RUBY_ENGINE == "ruby"
require "pry"
require "active_record"
require "delayed_job"
require "delayed_job_active_record"
require "sentry-ruby"
require 'simplecov'
SimpleCov.start do
project_name "sentry-delayed_job"
root File.join(__FILE__, "../../../")
coverage_dir File.join(__FILE__, "../../coverage")
end
if ENV["CI"]
require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
end
require "sentry-delayed_job"
DUMMY_DSN = 'http://12345:67890@sentry.localdomain/sentry/42'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.before :each do
# Make sure we reset the env in case something leaks in
ENV.delete('SENTRY_DSN')
ENV.delete('SENTRY_CURRENT_ENV')
ENV.delete('SENTRY_ENVIRONMENT')
ENV.delete('SENTRY_RELEASE')
ENV.delete('RACK_ENV')
end
end
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
# ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :delayed_jobs do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
table.text :handler, null: false # YAML-encoded string of the object that will do work
table.text :last_error # reason for last failure (See Note below)
table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
table.datetime :locked_at # Set when a client is working on this object
table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
table.string :locked_by # Who is working on this object (if locked)
table.string :queue # The name of the queue this job is in
table.timestamps null: true
end
end
def build_exception
1 / 0
rescue ZeroDivisionError => e
e
end
def perform_basic_setup
Sentry.init do |config|
config.dsn = DUMMY_DSN
config.logger = ::Logger.new(nil)
config.background_worker_threads = 0
config.transport.transport_class = Sentry::DummyTransport
yield(config) if block_given?
end
end