-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathspec_helper.rb
93 lines (65 loc) · 1.8 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
# frozen_string_literal: true
require "pathname"
require_relative "support/coverage"
require_relative "support/warnings"
require_relative "support/rspec_options"
Warning.ignore(%r{gems/i18n})
Warning.ignore(/byebug/)
Warning.process { |w| raise w }
begin
require "pry-byebug"
rescue LoadError; end
SPEC_ROOT = Pathname(__dir__)
Dir[SPEC_ROOT.join("shared/**/*.rb")].each(&method(:require))
Dir[SPEC_ROOT.join("support/**/*.rb")].each(&method(:require))
Warning.ignore(%r{rspec/matchers})
require "super_diff/rspec"
require "dry/schema"
require "dry/types"
Types = Dry.Types
Undefined = Dry::Core::Constants::Undefined
Dry::Schema.load_extensions(:hints)
require "i18n"
require "dry/schema/messages/i18n"
require "dry/schema/message_set"
module MessageSetSupport
def eql?(other)
to_h.eql?(other)
end
end
Dry::Schema::MessageSet.include(MessageSetSupport)
require "transproc/all"
module Coercions
extend Transproc::Registry
import Transproc::Recursion
import Transproc::HashTransformations
T = self
def stringify_keys(hash)
T[:hash_recursion, T[:stringify_keys]].(hash)
end
end
require "dry/configurable/test_interface"
Dry::Schema.config.enable_test_interface
RSpec.configure do |config|
config.example_status_persistence_file_path = "spec/examples.txt"
config.order = "random"
config.include PredicatesIntegration
config.include Coercions
config.before do
stub_const("Test", Module.new)
end
config.before(:all) do
Dry::Schema.config.reset_config
end
config.before do
Dry::Schema.config.reset_config
end
config.after do
I18n.load_path = [Dry::Schema::DEFAULT_MESSAGES_PATH]
I18n.locale = :en
I18n.reload!
%i[YAML I18n].each do |backend|
Dry::Schema::Messages.const_get(backend).instance_variable_set("@cache", nil)
end
end
end