forked from Shopify/shipit-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_helper.rb
89 lines (74 loc) · 2.16 KB
/
test_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
# frozen_string_literal: true
ENV["RAILS_ENV"] ||= "test"
if Warning.respond_to?(:[]=)
Warning[:deprecated] = true
end
require 'simplecov'
SimpleCov.start('rails') do
enable_coverage :branch
end
require 'webmock/minitest'
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
ActiveRecord::Migrator.migrations_paths = [
File.expand_path('../../test/dummy/db/migrate', __FILE__),
File.expand_path('../../db/migrate', __FILE__),
]
require 'rails/test_help'
require 'mocha/minitest'
require 'spy/integration'
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
ActiveSupport::TestCase.fixture_paths << File.expand_path("../fixtures", __FILE__)
ActiveSupport::TestCase.fixtures(:all)
end
Dir[File.expand_path('../helpers/**/*.rb', __FILE__)].each do |helper|
require helper
end
begin
require 'pry'
rescue LoadError
end
# FIXME: We need to get rid of active_model_serializers
# This is a monkey patch for Ruby 2.7+ compatibility
module ActionController
module SerializationAssertions
def process(*, **)
@serializers = Hash.new(0)
super
end
end
end
module ActiveSupport
class TestCase
include PayloadsHelper
include FixtureAliasesHelper
include QueriesHelper
include JSONHelper
include LinksHelper
include ApiHelper
include HooksHelper
include ActiveJob::TestHelper
setup do
@routes = Shipit::Engine.routes
Shipit.github.api.stubs(:login).returns('shipit')
end
teardown do
Shipit.redis.flushdb
Shipit.instance_variable_names.each do |name|
next if %w(@mocha @redis).include?(name)
Shipit.remove_instance_variable(name)
end
end
ActiveRecord::Migration.check_all_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
private
def resource(data)
Sawyer::Resource.new(Sawyer::Agent.new('http://example.com'), data)
end
end
end