assert 2.18.4 → 2.19.4
Sign up to get free protection for your applications and to get access to all the features.
- 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 +22 -8
- data/lib/assert/config_helpers.rb +57 -22
- data/lib/assert/context.rb +28 -47
- 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 +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 +182 -144
- data/test/system/test_tests.rb +88 -60
- data/test/unit/actual_value_tests.rb +103 -46
- data/test/unit/assert_tests.rb +48 -40
- data/test/unit/assertions/assert_block_tests.rb +12 -10
- data/test/unit/assertions/assert_changes_tests.rb +103 -0
- data/test/unit/assertions/assert_empty_tests.rb +16 -12
- data/test/unit/assertions/assert_equal_tests.rb +46 -24
- 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 +34 -23
- 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 +25 -17
- data/test/unit/config_helpers_tests.rb +15 -8
- 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 +43 -19
- 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 +42 -24
- data/test/unit/test_tests.rb +66 -73
- 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 +40 -9
- 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,38 +119,48 @@ 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)
|
113
127
|
end
|
114
128
|
|
115
|
-
def file_name
|
116
|
-
|
129
|
+
def file_name
|
130
|
+
file_line.file
|
131
|
+
end
|
132
|
+
|
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
|
-
|
151
|
+
def ==(other)
|
152
|
+
if other.is_a?(self.class)
|
153
|
+
type == other.type && message == other.message
|
154
|
+
else
|
155
|
+
super
|
156
|
+
end
|
133
157
|
end
|
134
158
|
|
135
159
|
def inspect
|
136
160
|
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} "\
|
137
|
-
"@message=#{
|
138
|
-
"@file_line=#{
|
139
|
-
"@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}>"
|
140
164
|
end
|
141
165
|
|
142
166
|
private
|
@@ -146,10 +170,10 @@ module Assert::Result
|
|
146
170
|
# filtered line of the backtrace). This is overridden for error results
|
147
171
|
# as they always show their full backtrace.
|
148
172
|
def build_trace
|
149
|
-
if
|
150
|
-
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)])
|
151
175
|
else
|
152
|
-
|
176
|
+
src_line
|
153
177
|
end
|
154
178
|
end
|
155
179
|
|
@@ -162,13 +186,23 @@ module Assert::Result
|
|
162
186
|
end
|
163
187
|
|
164
188
|
class Pass < Base
|
165
|
-
def self.type
|
166
|
-
|
189
|
+
def self.type
|
190
|
+
:pass
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.name
|
194
|
+
"Pass"
|
195
|
+
end
|
167
196
|
end
|
168
197
|
|
169
198
|
class Ignore < Base
|
170
|
-
def self.type
|
171
|
-
|
199
|
+
def self.type
|
200
|
+
:ignore
|
201
|
+
end
|
202
|
+
|
203
|
+
def self.name
|
204
|
+
"Ignore"
|
205
|
+
end
|
172
206
|
end
|
173
207
|
|
174
208
|
class HaltingTestResultError < RuntimeError
|
@@ -179,17 +213,26 @@ module Assert::Result
|
|
179
213
|
TestFailure = Class.new(HaltingTestResultError)
|
180
214
|
|
181
215
|
class Fail < Base
|
182
|
-
def self.type
|
183
|
-
|
216
|
+
def self.type
|
217
|
+
:fail
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.name
|
221
|
+
"Fail"
|
222
|
+
end
|
184
223
|
|
185
|
-
# fail results can be generated manually or by raising
|
224
|
+
# fail results can be generated manually or by raising
|
225
|
+
# Assert::Result::TestFailure
|
186
226
|
def self.for_test(test, msg_or_err, bt = nil)
|
187
|
-
if msg_or_err.
|
227
|
+
if msg_or_err.is_a?(TestFailure)
|
188
228
|
super(test, msg_or_err.message, msg_or_err.backtrace).tap do |result|
|
189
229
|
result.set_with_bt(msg_or_err.assert_with_bt)
|
190
230
|
end
|
191
|
-
elsif msg_or_err.
|
192
|
-
raise
|
231
|
+
elsif msg_or_err.is_a?(Exception)
|
232
|
+
raise(
|
233
|
+
ArgumentError,
|
234
|
+
"generate fail results by raising Assert::Result::TestFailure",
|
235
|
+
)
|
193
236
|
else
|
194
237
|
super(test, msg_or_err, bt)
|
195
238
|
end
|
@@ -200,17 +243,25 @@ module Assert::Result
|
|
200
243
|
TestSkipped = Class.new(HaltingTestResultError)
|
201
244
|
|
202
245
|
class Skip < Base
|
203
|
-
def self.type
|
204
|
-
|
246
|
+
def self.type
|
247
|
+
:skip
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.name
|
251
|
+
"Skip"
|
252
|
+
end
|
205
253
|
|
206
254
|
# skip results are generated by raising Assert::Result::TestSkipped
|
207
255
|
def self.for_test(test, msg_or_err, bt = nil)
|
208
|
-
if msg_or_err.
|
256
|
+
if msg_or_err.is_a?(TestSkipped)
|
209
257
|
super(test, msg_or_err.message, msg_or_err.backtrace).tap do |result|
|
210
258
|
result.set_with_bt(msg_or_err.assert_with_bt)
|
211
259
|
end
|
212
|
-
elsif msg_or_err.
|
213
|
-
raise
|
260
|
+
elsif msg_or_err.is_a?(Exception)
|
261
|
+
raise(
|
262
|
+
ArgumentError,
|
263
|
+
"generate skip results by raising Assert::Result::TestSkipped",
|
264
|
+
)
|
214
265
|
else
|
215
266
|
super(test, msg_or_err, bt)
|
216
267
|
end
|
@@ -218,12 +269,17 @@ module Assert::Result
|
|
218
269
|
end
|
219
270
|
|
220
271
|
class Error < Base
|
221
|
-
def self.type
|
222
|
-
|
272
|
+
def self.type
|
273
|
+
:error
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.name
|
277
|
+
"Error"
|
278
|
+
end
|
223
279
|
|
224
280
|
# error results are generated by raising exceptions in tests
|
225
281
|
def self.for_test(test, err)
|
226
|
-
if err.
|
282
|
+
if err.is_a?(Exception)
|
227
283
|
super(test, "#{err.message} (#{err.class.name})", err.backtrace)
|
228
284
|
else
|
229
285
|
raise ArgumentError, "generate error results by raising an exception"
|
@@ -239,10 +295,10 @@ module Assert::Result
|
|
239
295
|
end
|
240
296
|
|
241
297
|
class Backtrace < ::Array
|
242
|
-
DELIM = "\n"
|
298
|
+
DELIM = "\n"
|
243
299
|
|
244
300
|
def self.parse(bt)
|
245
|
-
|
301
|
+
new(bt.to_s.split(DELIM))
|
246
302
|
end
|
247
303
|
|
248
304
|
def self.to_s(bt_array)
|
@@ -254,7 +310,7 @@ module Assert::Result
|
|
254
310
|
end
|
255
311
|
|
256
312
|
def filtered
|
257
|
-
self.class.new(
|
313
|
+
self.class.new(reject{ |line| filter_out?(line.to_s) })
|
258
314
|
end
|
259
315
|
|
260
316
|
protected
|
@@ -264,8 +320,8 @@ module Assert::Result
|
|
264
320
|
# "./lib" in project dir, or "/usr/local/blahblah" if installed
|
265
321
|
assert_lib_path = File.expand_path("../..", __FILE__)
|
266
322
|
assert_macros_path = File.join(assert_lib_path, "assert/macros")
|
267
|
-
assert_bin_regex = /
|
268
|
-
(
|
323
|
+
assert_bin_regex = %r{bin/assert\:}
|
324
|
+
(line.rindex(assert_lib_path, 0) &&
|
269
325
|
!line.rindex(assert_macros_path, 0)
|
270
326
|
) ||
|
271
327
|
line =~ assert_bin_regex
|