assert 2.18.3 → 2.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/assert.gemspec +11 -5
- data/bin/assert +1 -0
- data/lib/assert.rb +20 -6
- data/lib/assert/actual_value.rb +26 -8
- data/lib/assert/assert_runner.rb +38 -17
- data/lib/assert/assertions.rb +145 -41
- data/lib/assert/cli.rb +19 -66
- data/lib/assert/clirb.rb +55 -0
- data/lib/assert/config.rb +9 -7
- data/lib/assert/config_helpers.rb +57 -22
- data/lib/assert/context.rb +33 -49
- data/lib/assert/context/let_dsl.rb +10 -4
- data/lib/assert/context/method_missing.rb +3 -0
- data/lib/assert/context/setup_dsl.rb +24 -16
- data/lib/assert/context/subject_dsl.rb +26 -25
- data/lib/assert/context/suite_dsl.rb +5 -1
- data/lib/assert/context/test_dsl.rb +58 -19
- data/lib/assert/context_info.rb +2 -0
- data/lib/assert/default_runner.rb +2 -0
- data/lib/assert/default_suite.rb +27 -15
- data/lib/assert/default_view.rb +49 -30
- data/lib/assert/factory.rb +2 -0
- data/lib/assert/file_line.rb +8 -6
- data/lib/assert/macro.rb +3 -1
- data/lib/assert/macros/methods.rb +73 -45
- data/lib/assert/result.rb +117 -61
- data/lib/assert/runner.rb +70 -51
- data/lib/assert/stub.rb +44 -3
- data/lib/assert/suite.rb +76 -38
- data/lib/assert/test.rb +43 -44
- data/lib/assert/utils.rb +22 -11
- data/lib/assert/version.rb +3 -1
- data/lib/assert/view.rb +46 -18
- data/lib/assert/view_helpers.rb +102 -92
- data/test/helper.rb +8 -4
- data/test/support/factory.rb +40 -21
- data/test/support/inherited_stuff.rb +2 -0
- data/test/system/stub_tests.rb +272 -250
- data/test/system/test_tests.rb +89 -73
- data/test/unit/actual_value_tests.rb +103 -46
- data/test/unit/assert_tests.rb +49 -39
- data/test/unit/assertions/assert_block_tests.rb +14 -14
- data/test/unit/assertions/assert_changes_tests.rb +103 -0
- data/test/unit/assertions/assert_empty_tests.rb +18 -16
- data/test/unit/assertions/assert_equal_tests.rb +48 -32
- data/test/unit/assertions/assert_file_exists_tests.rb +19 -17
- data/test/unit/assertions/assert_includes_tests.rb +14 -14
- data/test/unit/assertions/assert_instance_of_tests.rb +18 -18
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +14 -14
- data/test/unit/assertions/assert_nil_tests.rb +20 -16
- data/test/unit/assertions/assert_raises_tests.rb +36 -27
- data/test/unit/assertions/assert_respond_to_tests.rb +14 -14
- data/test/unit/assertions/assert_same_tests.rb +28 -32
- data/test/unit/assertions/assert_true_false_tests.rb +38 -32
- data/test/unit/assertions_tests.rb +25 -18
- data/test/unit/config_helpers_tests.rb +20 -9
- data/test/unit/config_tests.rb +16 -8
- data/test/unit/context/let_dsl_tests.rb +2 -0
- data/test/unit/context/setup_dsl_tests.rb +27 -15
- data/test/unit/context/subject_dsl_tests.rb +5 -4
- data/test/unit/context/suite_dsl_tests.rb +6 -5
- data/test/unit/context/test_dsl_tests.rb +43 -19
- data/test/unit/context_info_tests.rb +12 -3
- data/test/unit/context_tests.rb +166 -116
- data/test/unit/default_runner_tests.rb +2 -0
- data/test/unit/default_suite_tests.rb +17 -5
- data/test/unit/factory_tests.rb +5 -1
- data/test/unit/file_line_tests.rb +14 -12
- data/test/unit/macro_tests.rb +17 -10
- data/test/unit/result_tests.rb +72 -75
- data/test/unit/runner_tests.rb +38 -23
- data/test/unit/suite_tests.rb +48 -30
- data/test/unit/test_tests.rb +88 -102
- data/test/unit/utils_tests.rb +53 -36
- data/test/unit/view_helpers_tests.rb +25 -17
- data/test/unit/view_tests.rb +8 -5
- metadata +40 -9
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -68
data/lib/assert/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/config_helpers"
|
2
4
|
require "assert/suite"
|
3
5
|
require "assert/view"
|
@@ -12,21 +14,21 @@ module Assert
|
|
12
14
|
@config = config
|
13
15
|
end
|
14
16
|
|
15
|
-
def runner
|
17
|
+
def runner
|
18
|
+
self
|
19
|
+
end
|
16
20
|
|
17
21
|
def run
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if
|
23
|
-
|
24
|
-
elsif
|
25
|
-
|
26
|
-
end
|
27
|
-
if self.tests_to_run?
|
28
|
-
self.view.puts ", seeded with \"#{self.runner_seed}\""
|
22
|
+
on_start
|
23
|
+
suite.on_start
|
24
|
+
view.on_start
|
25
|
+
|
26
|
+
if single_test?
|
27
|
+
view.print "Running test: #{single_test_file_line}"
|
28
|
+
elsif tests_to_run?
|
29
|
+
view.print "Running tests in random order"
|
29
30
|
end
|
31
|
+
view.puts ", seeded with \"#{runner_seed}\"" if tests_to_run?
|
30
32
|
|
31
33
|
@current_running_test = nil
|
32
34
|
|
@@ -34,46 +36,46 @@ module Assert
|
|
34
36
|
# (Ctrl+T on Macs), process it
|
35
37
|
if Signal.list.keys.include?("INFO")
|
36
38
|
Signal.trap("INFO") do
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
on_info(@current_running_test)
|
40
|
+
suite.on_info(@current_running_test)
|
41
|
+
view.on_info(@current_running_test)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
begin
|
44
|
-
|
45
|
-
|
46
|
-
tests_to_run.tap{
|
46
|
+
suite.start_time = Time.now
|
47
|
+
suite.setups.each(&:call)
|
48
|
+
tests_to_run.tap{ suite.clear_tests_to_run }.delete_if do |test|
|
47
49
|
@current_running_test = test
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
before_test(test)
|
52
|
+
suite.before_test(test)
|
53
|
+
view.before_test(test)
|
52
54
|
test.run do |result|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
on_result(result)
|
56
|
+
suite.on_result(result)
|
57
|
+
view.on_result(result)
|
56
58
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
after_test(test)
|
60
|
+
suite.after_test(test)
|
61
|
+
view.after_test(test)
|
60
62
|
|
61
63
|
# always delete `test` from `tests_to_run` since it has been run
|
62
64
|
true
|
63
65
|
end
|
64
|
-
|
65
|
-
|
66
|
-
rescue Interrupt =>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
raise(
|
66
|
+
suite.teardowns.each(&:call)
|
67
|
+
suite.end_time = Time.now
|
68
|
+
rescue Interrupt => ex
|
69
|
+
on_interrupt(ex)
|
70
|
+
suite.on_interrupt(ex)
|
71
|
+
view.on_interrupt(ex)
|
72
|
+
raise(ex)
|
71
73
|
end
|
72
74
|
|
73
|
-
(
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
(fail_result_count + error_result_count).tap do
|
76
|
+
view.on_finish
|
77
|
+
suite.on_finish
|
78
|
+
on_finish
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -82,24 +84,41 @@ module Assert
|
|
82
84
|
# define callback handlers to do special behavior during the test run. These
|
83
85
|
# will be called by the test runner
|
84
86
|
|
85
|
-
def before_load(test_files)
|
86
|
-
|
87
|
-
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
def
|
92
|
-
|
93
|
-
|
87
|
+
def before_load(test_files)
|
88
|
+
end
|
89
|
+
|
90
|
+
def after_load
|
91
|
+
end
|
92
|
+
|
93
|
+
def on_start
|
94
|
+
end
|
95
|
+
|
96
|
+
def before_test(test)
|
97
|
+
end
|
98
|
+
|
99
|
+
def on_result(result)
|
100
|
+
end
|
101
|
+
|
102
|
+
def after_test(test)
|
103
|
+
end
|
104
|
+
|
105
|
+
def on_finish
|
106
|
+
end
|
107
|
+
|
108
|
+
def on_info(test)
|
109
|
+
end
|
110
|
+
|
111
|
+
def on_interrupt(err)
|
112
|
+
end
|
94
113
|
|
95
114
|
private
|
96
115
|
|
97
116
|
def tests_to_run
|
98
|
-
srand
|
99
|
-
if
|
100
|
-
[
|
117
|
+
srand runner_seed
|
118
|
+
if single_test?
|
119
|
+
[suite.find_test_to_run(single_test_file_line)].compact
|
101
120
|
else
|
102
|
-
|
121
|
+
suite.sorted_tests_to_run{ rand tests_to_run_count }
|
103
122
|
end
|
104
123
|
end
|
105
124
|
end
|
data/lib/assert/stub.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "much-stub"
|
2
4
|
|
3
5
|
module Assert
|
@@ -25,9 +27,9 @@ module Assert
|
|
25
27
|
orig_caller = caller_locations
|
26
28
|
begin
|
27
29
|
MuchStub.stub_send(*args, &block)
|
28
|
-
rescue MuchStub::NotStubbedError =>
|
29
|
-
|
30
|
-
raise
|
30
|
+
rescue MuchStub::NotStubbedError => ex
|
31
|
+
ex.set_backtrace(orig_caller.map(&:to_s))
|
32
|
+
raise ex
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -42,4 +44,43 @@ module Assert
|
|
42
44
|
def self.stub_spy(*args, &block)
|
43
45
|
MuchStub.spy(*args, &block)
|
44
46
|
end
|
47
|
+
|
48
|
+
StubCall = MuchStub::Call
|
49
|
+
class StubCall
|
50
|
+
def self.name
|
51
|
+
super.gsub("MuchStub::Call", "Assert::StubCall")
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.to_s
|
55
|
+
super.gsub("MuchStub::Call", "Assert::StubCall")
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.inspect
|
59
|
+
super.gsub("MuchStub::Call", "Assert::StubCall")
|
60
|
+
end
|
61
|
+
|
62
|
+
def inspect
|
63
|
+
super.gsub("MuchStub::Call", "Assert::StubCall")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
StubCallSpy = MuchStub::CallSpy
|
68
|
+
class StubCallSpy
|
69
|
+
def self.name
|
70
|
+
super.gsub("MuchStub::CallSpy", "Assert::StubCallSpy")
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.to_s
|
74
|
+
super.gsub("MuchStub::CallSpy", "Assert::StubCallSpy")
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.inspect
|
78
|
+
super.gsub("MuchStub::CallSpy", "Assert::StubCallSpy")
|
79
|
+
end
|
80
|
+
|
81
|
+
# See MuchStub::CallSpy#inspect.
|
82
|
+
def inspect
|
83
|
+
"#<Assert::StubCallSpy:#{"0x0%x" % (__id__ << 1)}>"
|
84
|
+
end
|
85
|
+
end
|
45
86
|
end
|
data/lib/assert/suite.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/config_helpers"
|
2
4
|
require "assert/test"
|
3
5
|
|
@@ -10,39 +12,46 @@ module Assert
|
|
10
12
|
class Suite
|
11
13
|
include Assert::ConfigHelpers
|
12
14
|
|
13
|
-
TEST_METHOD_REGEX = /^test./.freeze
|
14
|
-
|
15
15
|
# A suite is a set of tests to run. When a test class subclasses
|
16
16
|
# the Context class, that test class is pushed to the suite.
|
17
17
|
|
18
|
-
attr_reader :config, :
|
18
|
+
attr_reader :config, :setups, :teardowns
|
19
19
|
attr_accessor :start_time, :end_time
|
20
20
|
|
21
21
|
def initialize(config)
|
22
|
-
@config
|
23
|
-
@tests
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@end_time = @start_time
|
22
|
+
@config = config
|
23
|
+
@tests = []
|
24
|
+
@setups = []
|
25
|
+
@teardowns = []
|
26
|
+
@start_time = Time.now
|
27
|
+
@end_time = @start_time
|
29
28
|
end
|
30
29
|
|
31
|
-
def suite
|
30
|
+
def suite
|
31
|
+
self
|
32
|
+
end
|
32
33
|
|
33
34
|
def setup(&block)
|
34
|
-
|
35
|
+
setups << (block || proc{})
|
35
36
|
end
|
36
37
|
alias_method :startup, :setup
|
37
38
|
|
38
39
|
def teardown(&block)
|
39
|
-
|
40
|
+
teardowns << (block || proc{})
|
40
41
|
end
|
41
42
|
alias_method :shutdown, :teardown
|
42
43
|
|
43
|
-
def tests_to_run
|
44
|
-
|
45
|
-
|
44
|
+
def tests_to_run?
|
45
|
+
@tests.any?
|
46
|
+
end
|
47
|
+
|
48
|
+
def tests_to_run_count
|
49
|
+
@tests.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def clear_tests_to_run
|
53
|
+
@tests.clear
|
54
|
+
end
|
46
55
|
|
47
56
|
def find_test_to_run(file_line)
|
48
57
|
@tests.find{ |t| t.file_line == file_line }
|
@@ -52,32 +61,46 @@ module Assert
|
|
52
61
|
@tests.sort.sort_by(&sort_by_proc)
|
53
62
|
end
|
54
63
|
|
55
|
-
def test_count
|
56
|
-
|
57
|
-
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
def
|
64
|
+
def test_count
|
65
|
+
end
|
66
|
+
|
67
|
+
def result_count
|
68
|
+
end
|
69
|
+
|
70
|
+
def pass_result_count
|
71
|
+
end
|
72
|
+
|
73
|
+
def fail_result_count
|
74
|
+
end
|
75
|
+
|
76
|
+
def error_result_count
|
77
|
+
end
|
78
|
+
|
79
|
+
def skip_result_count
|
80
|
+
end
|
81
|
+
|
82
|
+
def ignore_result_count
|
83
|
+
end
|
62
84
|
|
63
85
|
def run_time
|
64
86
|
@end_time - @start_time
|
65
87
|
end
|
66
88
|
|
67
89
|
def test_rate
|
68
|
-
get_rate(
|
90
|
+
get_rate(test_count, run_time)
|
69
91
|
end
|
70
92
|
|
71
93
|
def result_rate
|
72
|
-
get_rate(
|
94
|
+
get_rate(result_count, run_time)
|
73
95
|
end
|
74
96
|
|
75
97
|
# Callbacks
|
76
98
|
|
77
|
-
# define callback handlers to do special behavior during the test run.
|
78
|
-
# will be called by the test runner
|
99
|
+
# define callback handlers to do special behavior during the test run.
|
100
|
+
# These will be called by the test runner.
|
79
101
|
|
80
|
-
def before_load(test_files)
|
102
|
+
def before_load(test_files)
|
103
|
+
end
|
81
104
|
|
82
105
|
# this is required to load tests into the suite, be sure to `super` if you
|
83
106
|
# override this method
|
@@ -85,19 +108,34 @@ module Assert
|
|
85
108
|
@tests << test
|
86
109
|
end
|
87
110
|
|
88
|
-
def after_load
|
89
|
-
|
90
|
-
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
def
|
95
|
-
|
111
|
+
def after_load
|
112
|
+
end
|
113
|
+
|
114
|
+
def on_start
|
115
|
+
end
|
116
|
+
|
117
|
+
def before_test(test)
|
118
|
+
end
|
119
|
+
|
120
|
+
def on_result(result)
|
121
|
+
end
|
122
|
+
|
123
|
+
def after_test(test)
|
124
|
+
end
|
125
|
+
|
126
|
+
def on_finish
|
127
|
+
end
|
128
|
+
|
129
|
+
def on_info(test)
|
130
|
+
end
|
131
|
+
|
132
|
+
def on_interrupt(err)
|
133
|
+
end
|
96
134
|
|
97
135
|
def inspect
|
98
136
|
"#<#{self.class}:#{"0x0%x" % (object_id << 1)}"\
|
99
|
-
" test_count=#{
|
100
|
-
" result_count=#{
|
137
|
+
" test_count=#{test_count.inspect}"\
|
138
|
+
" result_count=#{result_count.inspect}>"
|
101
139
|
end
|
102
140
|
end
|
103
141
|
end
|
data/lib/assert/test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "stringio"
|
2
4
|
require "assert/file_line"
|
3
5
|
require "assert/result"
|
@@ -7,24 +9,16 @@ module Assert
|
|
7
9
|
# Test is some code/method to run in the scope of a Context that may
|
8
10
|
# produce results.
|
9
11
|
def self.name_file_line_context_data(ci, name)
|
10
|
-
{ :
|
11
|
-
:
|
12
|
+
{ name: ci.test_name(name),
|
13
|
+
file_line: ci.called_from,
|
12
14
|
}
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.for_block(name, context_info, config, &block)
|
16
|
-
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
}))
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.for_method(method_name, context_info, config)
|
24
|
-
self.new(self.name_file_line_context_data(context_info, method_name).merge({
|
25
|
-
:context_info => context_info,
|
26
|
-
:config => config,
|
27
|
-
:code => proc{ self.send(method_name) }
|
18
|
+
new(name_file_line_context_data(context_info, name).merge({
|
19
|
+
context_info: context_info,
|
20
|
+
config: config,
|
21
|
+
code: block,
|
28
22
|
}))
|
29
23
|
end
|
30
24
|
|
@@ -37,15 +31,20 @@ module Assert
|
|
37
31
|
@file_line ||= FileLine.parse((@build_data[:file_line] || "").to_s)
|
38
32
|
end
|
39
33
|
|
40
|
-
def file_name
|
41
|
-
|
34
|
+
def file_name
|
35
|
+
file_line.file
|
36
|
+
end
|
37
|
+
|
38
|
+
def line_num
|
39
|
+
file_line.line.to_i
|
40
|
+
end
|
42
41
|
|
43
42
|
def name
|
44
43
|
@name ||= (@build_data[:name] || "")
|
45
44
|
end
|
46
45
|
|
47
46
|
def output
|
48
|
-
@output ||= (@build_data[:output] || "")
|
47
|
+
@output ||= (@build_data[:output] || +"")
|
49
48
|
end
|
50
49
|
|
51
50
|
def run_time
|
@@ -57,7 +56,7 @@ module Assert
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def context_class
|
60
|
-
|
59
|
+
context_info.klass
|
61
60
|
end
|
62
61
|
|
63
62
|
def config
|
@@ -70,22 +69,22 @@ module Assert
|
|
70
69
|
|
71
70
|
def run(&result_callback)
|
72
71
|
@result_callback = result_callback || proc{ |result| } # noop by default
|
73
|
-
scope =
|
72
|
+
scope = context_class.new(self, config, @result_callback)
|
74
73
|
start_time = Time.now
|
75
74
|
capture_output do
|
76
|
-
|
75
|
+
context_class.run_arounds(scope){ run_test(scope) }
|
77
76
|
end
|
78
77
|
@result_callback = nil
|
79
78
|
@run_time = Time.now - start_time
|
80
79
|
end
|
81
80
|
|
82
|
-
def <=>(
|
83
|
-
|
81
|
+
def <=>(other)
|
82
|
+
name <=> other.name
|
84
83
|
end
|
85
84
|
|
86
85
|
def inspect
|
87
86
|
attributes_string = ([:name, :context_info].collect do |attr|
|
88
|
-
"@#{attr}=#{
|
87
|
+
"@#{attr}=#{send(attr).inspect}"
|
89
88
|
end).join(" ")
|
90
89
|
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} #{attributes_string}>"
|
91
90
|
end
|
@@ -95,33 +94,33 @@ module Assert
|
|
95
94
|
def run_test(scope)
|
96
95
|
begin
|
97
96
|
# run any assert style "setup do" setups
|
98
|
-
|
97
|
+
context_class.run_setups(scope)
|
99
98
|
# run any test/unit style "def setup" setups
|
100
99
|
scope.setup if scope.respond_to?(:setup)
|
101
100
|
# run the code block
|
102
|
-
scope.instance_eval(&(
|
103
|
-
rescue Result::TestFailure =>
|
104
|
-
capture_result(Result::Fail,
|
105
|
-
rescue Result::TestSkipped =>
|
106
|
-
capture_result(Result::Skip,
|
107
|
-
rescue SignalException =>
|
108
|
-
raise(
|
109
|
-
rescue
|
110
|
-
capture_result(Result::Error,
|
101
|
+
scope.instance_eval(&(code || proc{}))
|
102
|
+
rescue Result::TestFailure => ex
|
103
|
+
capture_result(Result::Fail, ex)
|
104
|
+
rescue Result::TestSkipped => ex
|
105
|
+
capture_result(Result::Skip, ex)
|
106
|
+
rescue SignalException => ex
|
107
|
+
raise(ex)
|
108
|
+
rescue => ex
|
109
|
+
capture_result(Result::Error, ex)
|
111
110
|
ensure
|
112
111
|
begin
|
113
112
|
# run any assert style "teardown do" teardowns
|
114
|
-
|
113
|
+
context_class.run_teardowns(scope)
|
115
114
|
# run any test/unit style "def teardown" teardowns
|
116
115
|
scope.teardown if scope.respond_to?(:teardown)
|
117
|
-
rescue Result::TestFailure =>
|
118
|
-
capture_result(Result::Fail,
|
119
|
-
rescue Result::TestSkipped =>
|
120
|
-
capture_result(Result::Skip,
|
121
|
-
rescue SignalException =>
|
122
|
-
raise(
|
123
|
-
rescue
|
124
|
-
capture_result(Result::Error,
|
116
|
+
rescue Result::TestFailure => ex
|
117
|
+
capture_result(Result::Fail, ex)
|
118
|
+
rescue Result::TestSkipped => ex
|
119
|
+
capture_result(Result::Skip, ex)
|
120
|
+
rescue SignalException => ex
|
121
|
+
raise(ex)
|
122
|
+
rescue => ex
|
123
|
+
capture_result(Result::Error, ex)
|
125
124
|
end
|
126
125
|
end
|
127
126
|
end
|
@@ -131,7 +130,7 @@ module Assert
|
|
131
130
|
end
|
132
131
|
|
133
132
|
def capture_output(&block)
|
134
|
-
if
|
133
|
+
if config.capture_output == true
|
135
134
|
orig_stdout = $stdout.clone
|
136
135
|
$stdout = capture_io
|
137
136
|
block.call
|
@@ -142,7 +141,7 @@ module Assert
|
|
142
141
|
end
|
143
142
|
|
144
143
|
def capture_io
|
145
|
-
StringIO.new(
|
144
|
+
StringIO.new(output, "a+")
|
146
145
|
end
|
147
146
|
end
|
148
147
|
end
|