-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathspec_helper.rb
101 lines (73 loc) · 2.06 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
89
90
91
92
93
94
95
96
97
98
99
100
101
require 'bundler/setup'
Bundler.setup
require 'simplecov'
require 'coveralls'
require 'pry'
require 'active_support/notifications'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
SimpleCov.start do
add_filter 'spec'
end
require 'fakeredis/rspec'
require 'delayed_job'
require 'sidekiq'
require 'rspec-sidekiq'
Sidekiq::Testing.fake!
require 'resque'
require 'resque_spec'
ResqueSpec.disable_ext = false
require 'active_job'
ActiveJob::Base.queue_adapter = :test
class ApplicationJob < ActiveJob::Base
queue_as :not_used
end
# minimum rails gems for rspec/rails
require 'action_view'
require 'action_dispatch'
require 'action_controller'
require 'rspec/rails'
require 'taskinator'
Taskinator.configure do |config|
# use active support for instrumentation
config.instrumenter = ActiveSupport::Notifications
# use a "null stream" for logging
config.logger = Logger.new(File::NULL)
end
# require supporting files with custom matchers and macros, etc
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
config.mock_with :rspec do |c|
c.syntax = :expect
end
config.order = :random
config.fail_fast = (ENV["FAIL_FAST"] == 1)
config.before(:each) do
Taskinator.queue_adapter = :test_queue
end
config.before(:each, :redis => true) do
Taskinator.redis = { :namespace => "taskinator:test:#{SecureRandom.uuid}" }
end
config.before(:each, :sidekiq => true) do
Sidekiq::Worker.clear_all
end
config.before(:each, :delayed_job => true) do
Delayed::Job.clear_all
end
end
# require examples, must happen after configure
Dir[File.expand_path("../examples/**/*.rb", __FILE__)].each {|f| require f }
def recursively_enumerate_tasks(tasks, &block)
tasks.each do |task|
if task.is_a?(Taskinator::Task::SubProcess)
recursively_enumerate_tasks(task.sub_process.tasks, &block)
else
yield task
end
end
end