-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdefault.cr
51 lines (45 loc) · 1.26 KB
/
default.cr
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
module Spec2
module Runners
class Default
include Runner
extend Runner::Factory
def self.build
new
end
@current_context : Context?
getter current_context
def failed?
@failed
end
def run_context(reporter, order, context)
old_context = current_context
@current_context = context
reporter.context_started(context)
order.order(context.examples).each do |example|
begin
reporter.example_started(example)
example.__spec2_clear_lets
example.run
example.__spec2_clear_lets
reporter.example_succeeded(example)
rescue e : ExpectationNotMet
@failed = true
reporter.example_failed(example, e.with_example(example))
rescue e
@failed = true
reporter.example_errored(
example,
ExpectationNotMet.new(e.message, e).with_example(example),
)
end
end
order.order(context.contexts).each do |nested_context|
run_context(reporter, order, nested_context)
end
ensure
reporter.context_finished(context)
@current_context = old_context
end
end
end
end