-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathspec_helper.rb
96 lines (76 loc) · 2.08 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
# frozen_string_literal: true
require 'bundler/setup'
require 'cocoapods'
require 'cocoapods/bazel'
#-----------------------------------------------------------------------------#
module Pod
# Redirects the messages to an internal store.
#
module UI
class << self
undef puts, warn, print
attr_accessor :output
attr_accessor :warnings
def puts(message = '')
@output << "#{message}\n"
end
def warn(message = '', _actions = [])
@warnings << "#{message}\n"
end
def print(message)
@output << message
end
end
end
end
#-----------------------------------------------------------------------------#
RSpec.configure do |config|
config.before(:each) do
Pod::UI.output = ''.dup
Pod::UI.warnings = ''.dup
CLAide::ANSI.disabled = true
Pod::Config.instance = nil
ENV['CLAIDE_DISABLE_AUTO_WRAP'] = '1'
end
config.around(:each) do |test|
env = ENV.to_h.clone
test.run
ENV.replace(env)
end
config.around(:each, tmpdir: true) do |test|
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
test.run
end
end
end
# 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.extend(Module.new do
def describe_class_method(name, *args, &blk)
describe ".#{name}", *args do
let(:method_args) { [] }
subject(name) do
described_class.send(name, *method_args)
end
module_exec(&blk)
end
end
def describe_method(name, *args, &blk)
old_subject_name = instance_method(:subject).original_name
describe "##{name}", *args do
let(:method_args) { [] }
subject(name) do
prior_subject = old_subject_name ? send(old_subject_name) : super()
prior_subject.send(name, *method_args)
end
module_exec(&blk)
end
end
end)
end