assert 2.19.0 → 2.19.5
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 -6
- data/bin/assert +1 -0
- data/lib/assert.rb +20 -6
- data/lib/assert/actual_value.rb +11 -6
- data/lib/assert/assert_runner.rb +38 -17
- data/lib/assert/assertions.rb +85 -50
- data/lib/assert/cli.rb +32 -70
- data/lib/assert/clirb.rb +55 -0
- data/lib/assert/config.rb +22 -8
- data/lib/assert/config_helpers.rb +57 -22
- data/lib/assert/context.rb +16 -18
- data/lib/assert/context/let_dsl.rb +8 -2
- 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 +9 -7
- 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 +114 -62
- data/lib/assert/runner.rb +70 -51
- data/lib/assert/stub.rb +44 -3
- data/lib/assert/suite.rb +69 -28
- data/lib/assert/test.rb +43 -36
- 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 +182 -144
- data/test/system/test_tests.rb +88 -60
- data/test/unit/actual_value_tests.rb +71 -50
- data/test/unit/assert_tests.rb +42 -23
- data/test/unit/assertions/assert_block_tests.rb +12 -10
- data/test/unit/assertions/assert_changes_tests.rb +27 -21
- data/test/unit/assertions/assert_empty_tests.rb +16 -12
- data/test/unit/assertions/assert_equal_tests.rb +28 -26
- data/test/unit/assertions/assert_file_exists_tests.rb +17 -13
- data/test/unit/assertions/assert_includes_tests.rb +12 -10
- data/test/unit/assertions/assert_instance_of_tests.rb +16 -14
- data/test/unit/assertions/assert_is_a_tests.rb +128 -0
- data/test/unit/assertions/assert_match_tests.rb +12 -10
- data/test/unit/assertions/assert_nil_tests.rb +18 -12
- data/test/unit/assertions/assert_raises_tests.rb +29 -20
- data/test/unit/assertions/assert_respond_to_tests.rb +12 -10
- data/test/unit/assertions/assert_same_tests.rb +26 -24
- data/test/unit/assertions/assert_true_false_tests.rb +34 -24
- data/test/unit/assertions_tests.rb +16 -9
- data/test/unit/config_helpers_tests.rb +17 -10
- data/test/unit/config_tests.rb +36 -9
- data/test/unit/context/let_dsl_tests.rb +2 -0
- data/test/unit/context/setup_dsl_tests.rb +26 -14
- data/test/unit/context/subject_dsl_tests.rb +5 -3
- data/test/unit/context/suite_dsl_tests.rb +6 -4
- data/test/unit/context/test_dsl_tests.rb +39 -17
- data/test/unit/context_info_tests.rb +6 -4
- data/test/unit/context_tests.rb +112 -54
- data/test/unit/default_runner_tests.rb +2 -0
- data/test/unit/default_suite_tests.rb +12 -6
- data/test/unit/factory_tests.rb +4 -2
- data/test/unit/file_line_tests.rb +9 -7
- data/test/unit/macro_tests.rb +13 -11
- data/test/unit/result_tests.rb +49 -41
- data/test/unit/runner_tests.rb +33 -18
- data/test/unit/suite_tests.rb +39 -15
- data/test/unit/test_tests.rb +65 -50
- data/test/unit/utils_tests.rb +52 -37
- data/test/unit/view_helpers_tests.rb +23 -14
- data/test/unit/view_tests.rb +7 -5
- metadata +26 -11
- data/test/unit/assertions/assert_kind_of_tests.rb +0 -66
data/lib/assert/factory.rb
CHANGED
data/lib/assert/file_line.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Assert
|
2
4
|
class FileLine
|
3
5
|
def self.parse(file_line_path)
|
4
|
-
|
6
|
+
new(*(file_line_path.to_s.match(/(^[^\:]*)\:*(\d*).*$/) || [])[1..2])
|
5
7
|
end
|
6
8
|
|
7
9
|
attr_reader :file, :line
|
@@ -11,13 +13,13 @@ module Assert
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def to_s
|
14
|
-
"#{
|
16
|
+
"#{file}:#{line}"
|
15
17
|
end
|
16
18
|
|
17
|
-
def ==(
|
18
|
-
if
|
19
|
-
|
20
|
-
|
19
|
+
def ==(other)
|
20
|
+
if other.is_a?(FileLine)
|
21
|
+
file == other.file &&
|
22
|
+
line == other.line
|
21
23
|
else
|
22
24
|
super
|
23
25
|
end
|
data/lib/assert/macro.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Assert
|
2
4
|
class Macro < ::Proc
|
3
5
|
# this class is essentially a way to define a custom set of tests using
|
@@ -5,7 +7,7 @@ module Assert
|
|
5
7
|
# will be instance_eval'd in that Assert::Context.
|
6
8
|
attr_accessor :name
|
7
9
|
|
8
|
-
def initialize(name = nil, *
|
10
|
+
def initialize(name = nil, *_args)
|
9
11
|
raise ArgumentError unless block_given?
|
10
12
|
@name = name || "run this macro"
|
11
13
|
super()
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/macro"
|
2
4
|
|
3
5
|
module Assert::Macros
|
@@ -8,9 +10,12 @@ module Assert::Macros
|
|
8
10
|
|
9
11
|
module ClassMethods
|
10
12
|
def have_instance_method(*methods)
|
11
|
-
called_from =
|
13
|
+
called_from =
|
14
|
+
(methods.last.is_a?(Array) ? methods.pop : caller_locations).first
|
12
15
|
Assert::Macro.new do
|
13
|
-
methods.each
|
16
|
+
methods.each do |m|
|
17
|
+
_methods_macro_instance_methods << [m, called_from]
|
18
|
+
end
|
14
19
|
_methods_macro_test called_from
|
15
20
|
end
|
16
21
|
end
|
@@ -19,9 +24,12 @@ module Assert::Macros
|
|
19
24
|
alias_method :have_imeths, :have_instance_method
|
20
25
|
|
21
26
|
def not_have_instance_method(*methods)
|
22
|
-
called_from =
|
27
|
+
called_from =
|
28
|
+
(methods.last.is_a?(Array) ? methods.pop : caller_locations).first
|
23
29
|
Assert::Macro.new do
|
24
|
-
methods.each
|
30
|
+
methods.each do |m|
|
31
|
+
_methods_macro_not_instance_methods << [m, called_from]
|
32
|
+
end
|
25
33
|
_methods_macro_test called_from
|
26
34
|
end
|
27
35
|
end
|
@@ -30,7 +38,8 @@ module Assert::Macros
|
|
30
38
|
alias_method :not_have_imeths, :not_have_instance_method
|
31
39
|
|
32
40
|
def have_class_method(*methods)
|
33
|
-
called_from =
|
41
|
+
called_from =
|
42
|
+
(methods.last.is_a?(Array) ? methods.pop : caller_locations).first
|
34
43
|
Assert::Macro.new do
|
35
44
|
methods.each{ |m| _methods_macro_class_methods << [m, called_from] }
|
36
45
|
_methods_macro_test called_from
|
@@ -41,9 +50,12 @@ module Assert::Macros
|
|
41
50
|
alias_method :have_cmeths, :have_class_method
|
42
51
|
|
43
52
|
def not_have_class_method(*methods)
|
44
|
-
called_from =
|
53
|
+
called_from =
|
54
|
+
(methods.last.is_a?(Array) ? methods.pop : caller_locations).first
|
45
55
|
Assert::Macro.new do
|
46
|
-
methods.each
|
56
|
+
methods.each do |m|
|
57
|
+
_methods_macro_not_class_methods << [m, called_from]
|
58
|
+
end
|
47
59
|
_methods_macro_test called_from
|
48
60
|
end
|
49
61
|
end
|
@@ -52,44 +64,44 @@ module Assert::Macros
|
|
52
64
|
alias_method :not_have_cmeths, :not_have_class_method
|
53
65
|
|
54
66
|
def have_reader(*methods)
|
55
|
-
methods << caller_locations
|
67
|
+
methods << caller_locations unless methods.last.is_a?(Array)
|
56
68
|
have_instance_methods(*methods)
|
57
69
|
end
|
58
70
|
alias_method :have_readers, :have_reader
|
59
71
|
|
60
72
|
def not_have_reader(*methods)
|
61
|
-
methods << caller_locations
|
73
|
+
methods << caller_locations unless methods.last.is_a?(Array)
|
62
74
|
not_have_instance_methods(*methods)
|
63
75
|
end
|
64
76
|
alias_method :not_have_readers, :not_have_reader
|
65
77
|
|
66
78
|
def have_writer(*methods)
|
67
|
-
called = methods.last.
|
68
|
-
writer_meths = methods.collect{|m| "#{m}="}
|
79
|
+
called = methods.last.is_a?(Array) ? methods.pop : caller_locations
|
80
|
+
writer_meths = methods.collect{ |m| "#{m}=" }
|
69
81
|
writer_meths << called
|
70
82
|
have_instance_methods(*writer_meths)
|
71
83
|
end
|
72
84
|
alias_method :have_writers, :have_writer
|
73
85
|
|
74
86
|
def not_have_writer(*methods)
|
75
|
-
called = methods.last.
|
76
|
-
writer_meths = methods.collect{|m| "#{m}="}
|
87
|
+
called = methods.last.is_a?(Array) ? methods.pop : caller_locations
|
88
|
+
writer_meths = methods.collect{ |m| "#{m}=" }
|
77
89
|
writer_meths << called
|
78
90
|
not_have_instance_methods(*writer_meths)
|
79
91
|
end
|
80
92
|
alias_method :not_have_writers, :not_have_writer
|
81
93
|
|
82
94
|
def have_accessor(*methods)
|
83
|
-
called = methods.last.
|
84
|
-
accessor_meths = methods.collect{|m| [m, "#{m}="]}.flatten
|
95
|
+
called = methods.last.is_a?(Array) ? methods.pop : caller_locations
|
96
|
+
accessor_meths = methods.collect{ |m| [m, "#{m}="] }.flatten
|
85
97
|
accessor_meths << called
|
86
98
|
have_instance_methods(*accessor_meths)
|
87
99
|
end
|
88
100
|
alias_method :have_accessors, :have_accessor
|
89
101
|
|
90
102
|
def not_have_accessor(*methods)
|
91
|
-
called = methods.last.
|
92
|
-
accessor_meths = methods.collect{|m| [m, "#{m}="]}.flatten
|
103
|
+
called = methods.last.is_a?(Array) ? methods.pop : caller_locations
|
104
|
+
accessor_meths = methods.collect{ |m| [m, "#{m}="] }.flatten
|
93
105
|
accessor_meths << called
|
94
106
|
not_have_instance_methods(*accessor_meths)
|
95
107
|
end
|
@@ -98,35 +110,51 @@ module Assert::Macros
|
|
98
110
|
# private
|
99
111
|
|
100
112
|
def _methods_macro_test(called_from)
|
101
|
-
@_methods_macro_test ||=
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
113
|
+
@_methods_macro_test ||=
|
114
|
+
test "should respond to methods", called_from do
|
115
|
+
self
|
116
|
+
.class
|
117
|
+
._methods_macro_instance_methods
|
118
|
+
.each do |(method, called_from)|
|
119
|
+
msg =
|
120
|
+
"#{subject.class.name} does not have "\
|
121
|
+
"instance method ##{method}"
|
122
|
+
with_backtrace([called_from]) do
|
123
|
+
assert_that(subject).responds_to(method, msg)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
self
|
128
|
+
.class
|
129
|
+
._methods_macro_class_methods
|
130
|
+
.each do |(method, called_from)|
|
131
|
+
msg =
|
132
|
+
"#{subject.class.name} does not have class method ##{method}"
|
133
|
+
with_backtrace([called_from]) do
|
134
|
+
assert_that(subject.class).responds_to(method, msg)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
self
|
139
|
+
.class
|
140
|
+
._methods_macro_not_instance_methods
|
141
|
+
.each do |(method, called_from)|
|
142
|
+
msg = "#{subject.class.name} has instance method ##{method}"
|
143
|
+
with_backtrace([called_from]) do
|
144
|
+
assert_that(subject).does_not_respond_to(method, msg)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
self
|
149
|
+
.class
|
150
|
+
._methods_macro_not_class_methods
|
151
|
+
.each do |(method, called_from)|
|
152
|
+
msg = "#{subject.class.name} has class method ##{method}"
|
153
|
+
with_backtrace([called_from]) do
|
154
|
+
assert_that(subject.class).does_not_respond_to(method, msg)
|
155
|
+
end
|
156
|
+
end
|
114
157
|
end
|
115
|
-
|
116
|
-
self.class._methods_macro_not_instance_methods.each do |(method, called_from)|
|
117
|
-
msg = "#{subject.class.name} has instance method ##{method}"
|
118
|
-
with_backtrace([called_from]) do
|
119
|
-
assert_that(subject).does_not_respond_to(method, msg)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
self.class._methods_macro_not_class_methods.each do |(method, called_from)|
|
124
|
-
msg = "#{subject.class.name} has class method ##{method}"
|
125
|
-
with_backtrace([called_from]) do
|
126
|
-
assert_that(subject.class).does_not_respond_to(method, msg)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
158
|
end
|
131
159
|
|
132
160
|
def _methods_macro_instance_methods
|
data/lib/assert/result.rb
CHANGED
@@ -1,40 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/file_line"
|
2
4
|
|
3
5
|
module Assert; end
|
6
|
+
|
4
7
|
module Assert::Result
|
5
|
-
class Base
|
6
|
-
class Pass < Base
|
7
|
-
class Ignore < Base
|
8
|
-
class Fail < Base
|
9
|
-
class Error < Base
|
10
|
-
class Skip < Base
|
8
|
+
class Base; end
|
9
|
+
class Pass < Base; end
|
10
|
+
class Ignore < Base; end
|
11
|
+
class Fail < Base; end
|
12
|
+
class Error < Base; end
|
13
|
+
class Skip < Base; end
|
11
14
|
|
12
15
|
def self.types
|
13
|
-
@types ||= Hash.new{ |
|
16
|
+
@types ||= Hash.new{ |_h, _k| Base }.tap{ |hash|
|
14
17
|
hash[:pass] = Pass
|
15
18
|
hash[:fail] = Fail
|
16
19
|
hash[:ignore] = Ignore
|
17
20
|
hash[:skip] = Skip
|
18
21
|
hash[:error] = Error
|
19
|
-
|
22
|
+
}.freeze
|
20
23
|
end
|
21
24
|
|
22
25
|
def self.new(data = nil)
|
23
26
|
data ||= {}
|
24
|
-
|
27
|
+
types[data[:type]].new(data)
|
25
28
|
end
|
26
29
|
|
27
30
|
class Base
|
28
|
-
def self.type
|
29
|
-
|
31
|
+
def self.type
|
32
|
+
:unknown
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.name
|
36
|
+
""
|
37
|
+
end
|
30
38
|
|
31
39
|
def self.for_test(test, message, bt)
|
32
|
-
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
40
|
+
new({
|
41
|
+
test_name: test.name,
|
42
|
+
test_file_line: test.file_line,
|
43
|
+
message: message,
|
44
|
+
output: test.output,
|
45
|
+
backtrace: Backtrace.new(bt),
|
38
46
|
})
|
39
47
|
end
|
40
48
|
|
@@ -56,14 +64,20 @@ module Assert::Result
|
|
56
64
|
end
|
57
65
|
|
58
66
|
def test_file_line
|
59
|
-
@test_file_line ||=
|
67
|
+
@test_file_line ||=
|
68
|
+
(@build_data[:test_file_line] || Assert::FileLine.parse(""))
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_file_name
|
72
|
+
test_file_line.file
|
60
73
|
end
|
61
74
|
|
62
|
-
def
|
63
|
-
|
75
|
+
def test_line_num
|
76
|
+
test_file_line.line.to_i
|
77
|
+
end
|
64
78
|
|
65
79
|
def test_id
|
66
|
-
|
80
|
+
test_file_line.to_s
|
67
81
|
end
|
68
82
|
|
69
83
|
def message
|
@@ -105,32 +119,38 @@ module Assert::Result
|
|
105
119
|
end
|
106
120
|
|
107
121
|
def src_line
|
108
|
-
@src_line ||= first_filtered_bt_line(
|
122
|
+
@src_line ||= first_filtered_bt_line(backtrace)
|
109
123
|
end
|
110
124
|
|
111
125
|
def file_line
|
112
|
-
@file_line ||= Assert::FileLine.parse(
|
126
|
+
@file_line ||= Assert::FileLine.parse(src_line)
|
127
|
+
end
|
128
|
+
|
129
|
+
def file_name
|
130
|
+
file_line.file
|
113
131
|
end
|
114
132
|
|
115
|
-
def
|
116
|
-
|
133
|
+
def line_num
|
134
|
+
file_line.line.to_i
|
135
|
+
end
|
117
136
|
|
118
137
|
Assert::Result.types.keys.each do |type|
|
119
138
|
define_method("#{type}?"){ self.type == type }
|
120
139
|
end
|
121
140
|
|
122
|
-
def to_sym
|
141
|
+
def to_sym
|
142
|
+
type
|
143
|
+
end
|
123
144
|
|
124
145
|
def to_s
|
125
|
-
[
|
126
|
-
|
127
|
-
|
128
|
-
].reject(&:empty?).join("\n")
|
146
|
+
["#{name.upcase}: #{test_name}", message, trace]
|
147
|
+
.reject(&:empty?)
|
148
|
+
.join("\n")
|
129
149
|
end
|
130
150
|
|
131
|
-
def ==(
|
132
|
-
if
|
133
|
-
|
151
|
+
def ==(other)
|
152
|
+
if other.is_a?(self.class)
|
153
|
+
type == other.type && message == other.message
|
134
154
|
else
|
135
155
|
super
|
136
156
|
end
|
@@ -138,9 +158,9 @@ module Assert::Result
|
|
138
158
|
|
139
159
|
def inspect
|
140
160
|
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} "\
|
141
|
-
"@message=#{
|
142
|
-
"@file_line=#{
|
143
|
-
"@test_file_line=#{
|
161
|
+
"@message=#{message.inspect} "\
|
162
|
+
"@file_line=#{file_line.to_s.inspect} "\
|
163
|
+
"@test_file_line=#{test_file_line.to_s.inspect}>"
|
144
164
|
end
|
145
165
|
|
146
166
|
private
|
@@ -150,10 +170,10 @@ module Assert::Result
|
|
150
170
|
# filtered line of the backtrace). This is overridden for error results
|
151
171
|
# as they always show their full backtrace.
|
152
172
|
def build_trace
|
153
|
-
if
|
154
|
-
Backtrace.to_s(@with_bt+[first_filtered_bt_line(
|
173
|
+
if with_bt_set?
|
174
|
+
Backtrace.to_s(@with_bt + [first_filtered_bt_line(backtrace)])
|
155
175
|
else
|
156
|
-
|
176
|
+
src_line
|
157
177
|
end
|
158
178
|
end
|
159
179
|
|
@@ -166,13 +186,23 @@ module Assert::Result
|
|
166
186
|
end
|
167
187
|
|
168
188
|
class Pass < Base
|
169
|
-
def self.type
|
170
|
-
|
189
|
+
def self.type
|
190
|
+
:pass
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.name
|
194
|
+
"Pass"
|
195
|
+
end
|
171
196
|
end
|
172
197
|
|
173
198
|
class Ignore < Base
|
174
|
-
def self.type
|
175
|
-
|
199
|
+
def self.type
|
200
|
+
:ignore
|
201
|
+
end
|
202
|
+
|
203
|
+
def self.name
|
204
|
+
"Ignore"
|
205
|
+
end
|
176
206
|
end
|
177
207
|
|
178
208
|
class HaltingTestResultError < RuntimeError
|
@@ -183,17 +213,26 @@ module Assert::Result
|
|
183
213
|
TestFailure = Class.new(HaltingTestResultError)
|
184
214
|
|
185
215
|
class Fail < Base
|
186
|
-
def self.type
|
187
|
-
|
216
|
+
def self.type
|
217
|
+
:fail
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.name
|
221
|
+
"Fail"
|
222
|
+
end
|
188
223
|
|
189
|
-
# fail results can be generated manually or by raising
|
224
|
+
# fail results can be generated manually or by raising
|
225
|
+
# Assert::Result::TestFailure
|
190
226
|
def self.for_test(test, msg_or_err, bt = nil)
|
191
|
-
if msg_or_err.
|
227
|
+
if msg_or_err.is_a?(TestFailure)
|
192
228
|
super(test, msg_or_err.message, msg_or_err.backtrace).tap do |result|
|
193
229
|
result.set_with_bt(msg_or_err.assert_with_bt)
|
194
230
|
end
|
195
|
-
elsif msg_or_err.
|
196
|
-
raise
|
231
|
+
elsif msg_or_err.is_a?(Exception)
|
232
|
+
raise(
|
233
|
+
ArgumentError,
|
234
|
+
"generate fail results by raising Assert::Result::TestFailure",
|
235
|
+
)
|
197
236
|
else
|
198
237
|
super(test, msg_or_err, bt)
|
199
238
|
end
|
@@ -204,17 +243,25 @@ module Assert::Result
|
|
204
243
|
TestSkipped = Class.new(HaltingTestResultError)
|
205
244
|
|
206
245
|
class Skip < Base
|
207
|
-
def self.type
|
208
|
-
|
246
|
+
def self.type
|
247
|
+
:skip
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.name
|
251
|
+
"Skip"
|
252
|
+
end
|
209
253
|
|
210
254
|
# skip results are generated by raising Assert::Result::TestSkipped
|
211
255
|
def self.for_test(test, msg_or_err, bt = nil)
|
212
|
-
if msg_or_err.
|
256
|
+
if msg_or_err.is_a?(TestSkipped)
|
213
257
|
super(test, msg_or_err.message, msg_or_err.backtrace).tap do |result|
|
214
258
|
result.set_with_bt(msg_or_err.assert_with_bt)
|
215
259
|
end
|
216
|
-
elsif msg_or_err.
|
217
|
-
raise
|
260
|
+
elsif msg_or_err.is_a?(Exception)
|
261
|
+
raise(
|
262
|
+
ArgumentError,
|
263
|
+
"generate skip results by raising Assert::Result::TestSkipped",
|
264
|
+
)
|
218
265
|
else
|
219
266
|
super(test, msg_or_err, bt)
|
220
267
|
end
|
@@ -222,12 +269,17 @@ module Assert::Result
|
|
222
269
|
end
|
223
270
|
|
224
271
|
class Error < Base
|
225
|
-
def self.type
|
226
|
-
|
272
|
+
def self.type
|
273
|
+
:error
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.name
|
277
|
+
"Error"
|
278
|
+
end
|
227
279
|
|
228
280
|
# error results are generated by raising exceptions in tests
|
229
281
|
def self.for_test(test, err)
|
230
|
-
if err.
|
282
|
+
if err.is_a?(Exception)
|
231
283
|
super(test, "#{err.message} (#{err.class.name})", err.backtrace)
|
232
284
|
else
|
233
285
|
raise ArgumentError, "generate error results by raising an exception"
|
@@ -243,10 +295,10 @@ module Assert::Result
|
|
243
295
|
end
|
244
296
|
|
245
297
|
class Backtrace < ::Array
|
246
|
-
DELIM = "\n"
|
298
|
+
DELIM = "\n"
|
247
299
|
|
248
300
|
def self.parse(bt)
|
249
|
-
|
301
|
+
new(bt.to_s.split(DELIM))
|
250
302
|
end
|
251
303
|
|
252
304
|
def self.to_s(bt_array)
|
@@ -258,7 +310,7 @@ module Assert::Result
|
|
258
310
|
end
|
259
311
|
|
260
312
|
def filtered
|
261
|
-
self.class.new(
|
313
|
+
self.class.new(reject{ |line| filter_out?(line.to_s) })
|
262
314
|
end
|
263
315
|
|
264
316
|
protected
|
@@ -268,8 +320,8 @@ module Assert::Result
|
|
268
320
|
# "./lib" in project dir, or "/usr/local/blahblah" if installed
|
269
321
|
assert_lib_path = File.expand_path("../..", __FILE__)
|
270
322
|
assert_macros_path = File.join(assert_lib_path, "assert/macros")
|
271
|
-
assert_bin_regex = /
|
272
|
-
(
|
323
|
+
assert_bin_regex = %r{bin/assert\:}
|
324
|
+
(line.rindex(assert_lib_path, 0) &&
|
273
325
|
!line.rindex(assert_macros_path, 0)
|
274
326
|
) ||
|
275
327
|
line =~ assert_bin_regex
|