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/cli.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "benchmark"
|
2
4
|
require "set"
|
3
5
|
require "assert/assert_runner"
|
6
|
+
require "assert/clirb"
|
4
7
|
require "assert/version"
|
5
8
|
|
6
9
|
module Assert
|
@@ -22,13 +25,17 @@ module Assert
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def self.bench(start_msg, &block)
|
25
|
-
|
26
|
-
block.call
|
28
|
+
unless Assert.config.debug
|
29
|
+
block.call
|
30
|
+
return
|
27
31
|
end
|
32
|
+
|
28
33
|
print debug_start_msg(start_msg)
|
29
|
-
RoundedMillisecondTime
|
30
|
-
|
31
|
-
|
34
|
+
RoundedMillisecondTime
|
35
|
+
.new(Benchmark.measure(&block).real)
|
36
|
+
.tap do |time_in_ms|
|
37
|
+
puts debug_finish_msg(time_in_ms)
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def initialize(*args)
|
@@ -70,13 +77,13 @@ module Assert
|
|
70
77
|
puts help
|
71
78
|
rescue CLIRB::VersionExit
|
72
79
|
puts Assert::VERSION
|
73
|
-
rescue CLIRB::Error =>
|
74
|
-
puts "#{
|
75
|
-
puts
|
80
|
+
rescue CLIRB::Error => ex
|
81
|
+
puts "#{ex.message}\n\n"
|
82
|
+
puts Assert.config.debug ? ex.backtrace.join("\n") : help
|
76
83
|
exit(1)
|
77
|
-
rescue
|
78
|
-
puts "#{
|
79
|
-
puts
|
84
|
+
rescue => ex
|
85
|
+
puts "#{ex.class}: #{ex.message}"
|
86
|
+
puts ex.backtrace.join("\n")
|
80
87
|
exit(1)
|
81
88
|
end
|
82
89
|
exit(0)
|
@@ -91,63 +98,9 @@ module Assert
|
|
91
98
|
|
92
99
|
module RoundedMillisecondTime
|
93
100
|
ROUND_PRECISION = 3
|
94
|
-
ROUND_MODIFIER = 10
|
101
|
+
ROUND_MODIFIER = 10**ROUND_PRECISION
|
95
102
|
def self.new(time_in_seconds)
|
96
103
|
(time_in_seconds * 1000 * ROUND_MODIFIER).to_i / ROUND_MODIFIER.to_f
|
97
104
|
end
|
98
105
|
end
|
99
|
-
|
100
|
-
class CLIRB # Version 1.1.0, https://github.com/redding/cli.rb
|
101
|
-
Error = Class.new(RuntimeError);
|
102
|
-
HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
|
103
|
-
attr_reader :argv, :args, :opts, :data
|
104
|
-
|
105
|
-
def initialize(&block)
|
106
|
-
@options = []; instance_eval(&block) if block
|
107
|
-
require "optparse"
|
108
|
-
@data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
|
109
|
-
p.banner = ""; @options.each do |o|
|
110
|
-
@opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
|
111
|
-
end
|
112
|
-
p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
|
113
|
-
p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def option(*args); @options << Option.new(*args); end
|
118
|
-
def parse!(argv)
|
119
|
-
@args = (argv || []).dup.tap do |args_list|
|
120
|
-
begin; @parser.parse!(args_list)
|
121
|
-
rescue OptionParser::ParseError => err; raise Error, err.message; end
|
122
|
-
end; @data = @args + [@opts]
|
123
|
-
end
|
124
|
-
def to_s; @parser.to_s; end
|
125
|
-
def inspect
|
126
|
-
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
|
127
|
-
end
|
128
|
-
|
129
|
-
class Option
|
130
|
-
attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
|
131
|
-
|
132
|
-
def initialize(name, desc = nil, abbrev: nil, value: nil)
|
133
|
-
@name, @desc = name, desc || ""
|
134
|
-
@opt_name, @abbrev = parse_name_values(name, abbrev)
|
135
|
-
@value, @klass = gvalinfo(value)
|
136
|
-
@parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
|
137
|
-
["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
|
138
|
-
else
|
139
|
-
["-#{@abbrev}", "--#{@opt_name} VALUE", @klass, @desc]
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
private
|
144
|
-
|
145
|
-
def parse_name_values(name, custom_abbrev)
|
146
|
-
[ (processed_name = name.to_s.strip.downcase).gsub("_", "-"),
|
147
|
-
custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
|
148
|
-
]
|
149
|
-
end
|
150
|
-
def gvalinfo(v); v.kind_of?(Class) ? [nil,v] : [v,v.class]; end
|
151
|
-
end
|
152
|
-
end
|
153
106
|
end
|
data/lib/assert/clirb.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Assert
|
2
|
+
class CLIRB # Version 1.1.0, https://github.com/redding/cli.rb
|
3
|
+
Error = Class.new(RuntimeError);
|
4
|
+
HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
|
5
|
+
attr_reader :argv, :args, :opts, :data
|
6
|
+
|
7
|
+
def initialize(&block)
|
8
|
+
@options = []; instance_eval(&block) if block
|
9
|
+
require "optparse"
|
10
|
+
@data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
|
11
|
+
p.banner = ""; @options.each do |o|
|
12
|
+
@opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
|
13
|
+
end
|
14
|
+
p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
|
15
|
+
p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def option(*args); @options << Option.new(*args); end
|
20
|
+
def parse!(argv)
|
21
|
+
@args = (argv || []).dup.tap do |args_list|
|
22
|
+
begin; @parser.parse!(args_list)
|
23
|
+
rescue OptionParser::ParseError => err; raise Error, err.message; end
|
24
|
+
end; @data = @args + [@opts]
|
25
|
+
end
|
26
|
+
def to_s; @parser.to_s; end
|
27
|
+
def inspect
|
28
|
+
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
|
29
|
+
end
|
30
|
+
|
31
|
+
class Option
|
32
|
+
attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
|
33
|
+
|
34
|
+
def initialize(name, desc = nil, abbrev: nil, value: nil)
|
35
|
+
@name, @desc = name, desc || ""
|
36
|
+
@opt_name, @abbrev = parse_name_values(name, abbrev)
|
37
|
+
@value, @klass = gvalinfo(value)
|
38
|
+
@parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
|
39
|
+
["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
|
40
|
+
else
|
41
|
+
["-#{@abbrev}", "--#{@opt_name} VALUE", @klass, @desc]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_name_values(name, custom_abbrev)
|
48
|
+
[ (processed_name = name.to_s.strip.downcase).gsub("_", "-"),
|
49
|
+
custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
|
50
|
+
]
|
51
|
+
end
|
52
|
+
def gvalinfo(v); v.kind_of?(Class) ? [nil,v] : [v,v.class]; end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/assert/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/default_runner"
|
2
4
|
require "assert/default_suite"
|
3
5
|
require "assert/default_view"
|
@@ -9,7 +11,7 @@ module Assert
|
|
9
11
|
def self.settings(*items)
|
10
12
|
items.each do |item|
|
11
13
|
define_method(item) do |*args|
|
12
|
-
|
14
|
+
unless (value = args.size > 1 ? args : args.first).nil?
|
13
15
|
instance_variable_set("@#{item}", value)
|
14
16
|
end
|
15
17
|
instance_variable_get("@#{item}")
|
@@ -51,30 +53,30 @@ module Assert
|
|
51
53
|
@list = false
|
52
54
|
@debug = false
|
53
55
|
|
54
|
-
|
56
|
+
apply(settings || {})
|
55
57
|
end
|
56
58
|
|
57
59
|
def apply(settings)
|
58
60
|
settings.keys.each do |name|
|
59
|
-
if !settings[name].nil? &&
|
60
|
-
|
61
|
+
if !settings[name].nil? && respond_to?(name.to_s)
|
62
|
+
send(name.to_s, settings[name])
|
61
63
|
end
|
62
64
|
end
|
63
65
|
@single_test_file_line = nil
|
64
66
|
end
|
65
67
|
|
66
68
|
def single_test?
|
67
|
-
!
|
69
|
+
!single_test.empty?
|
68
70
|
end
|
69
71
|
|
70
72
|
def single_test_file_line
|
71
73
|
@single_test_file_line ||= Assert::FileLine.parse(
|
72
|
-
File.expand_path(
|
74
|
+
File.expand_path(single_test, Dir.pwd),
|
73
75
|
)
|
74
76
|
end
|
75
77
|
|
76
78
|
def single_test_file_path
|
77
|
-
|
79
|
+
single_test_file_line&.file
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -1,34 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Assert
|
2
4
|
module ConfigHelpers
|
3
|
-
def runner
|
4
|
-
|
5
|
-
|
5
|
+
def runner
|
6
|
+
config.runner
|
7
|
+
end
|
8
|
+
|
9
|
+
def suite
|
10
|
+
config.suite
|
11
|
+
end
|
12
|
+
|
13
|
+
def view
|
14
|
+
config.view
|
15
|
+
end
|
6
16
|
|
7
17
|
def runner_seed
|
8
|
-
|
18
|
+
config.runner_seed
|
9
19
|
end
|
10
20
|
|
11
21
|
def single_test?
|
12
|
-
|
22
|
+
config.single_test?
|
13
23
|
end
|
14
24
|
|
15
25
|
def single_test_file_line
|
16
|
-
|
26
|
+
config.single_test_file_line
|
27
|
+
end
|
28
|
+
|
29
|
+
def tests_to_run?
|
30
|
+
config.suite.tests_to_run?
|
31
|
+
end
|
32
|
+
|
33
|
+
def tests_to_run_count
|
34
|
+
config.suite.tests_to_run_count
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_count
|
38
|
+
config.suite.test_count
|
39
|
+
end
|
40
|
+
|
41
|
+
def result_count
|
42
|
+
config.suite.result_count
|
17
43
|
end
|
18
44
|
|
19
|
-
def
|
20
|
-
|
45
|
+
def pass_result_count
|
46
|
+
config.suite.pass_result_count
|
47
|
+
end
|
48
|
+
|
49
|
+
def fail_result_count
|
50
|
+
config.suite.fail_result_count
|
51
|
+
end
|
21
52
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def
|
27
|
-
|
28
|
-
|
53
|
+
def error_result_count
|
54
|
+
config.suite.error_result_count
|
55
|
+
end
|
56
|
+
|
57
|
+
def skip_result_count
|
58
|
+
config.suite.skip_result_count
|
59
|
+
end
|
60
|
+
|
61
|
+
def ignore_result_count
|
62
|
+
config.suite.ignore_result_count
|
63
|
+
end
|
29
64
|
|
30
65
|
def all_pass?
|
31
|
-
|
66
|
+
pass_result_count == result_count
|
32
67
|
end
|
33
68
|
|
34
69
|
def formatted_run_time(run_time, format = "%.6f")
|
@@ -44,29 +79,29 @@ module Assert
|
|
44
79
|
end
|
45
80
|
|
46
81
|
def formatted_suite_run_time(format = "%.6f")
|
47
|
-
formatted_run_time(
|
82
|
+
formatted_run_time(config.suite.run_time, format)
|
48
83
|
end
|
49
84
|
|
50
85
|
def formatted_suite_test_rate(format = "%.6f")
|
51
|
-
formatted_test_rate(
|
86
|
+
formatted_test_rate(config.suite.test_rate, format)
|
52
87
|
end
|
53
88
|
|
54
89
|
def formatted_suite_result_rate(format = "%.6f")
|
55
|
-
formatted_result_rate(
|
90
|
+
formatted_result_rate(config.suite.result_rate, format)
|
56
91
|
end
|
57
92
|
|
58
93
|
def show_test_profile_info?
|
59
|
-
!!
|
94
|
+
!!config.profile
|
60
95
|
end
|
61
96
|
|
62
97
|
def show_test_verbose_info?
|
63
|
-
!!
|
98
|
+
!!config.verbose
|
64
99
|
end
|
65
100
|
|
66
101
|
# return a list of result type symbols that have actually occurred
|
67
102
|
def ocurring_result_types
|
68
103
|
@result_types ||= [:pass, :fail, :ignore, :skip, :error].select do |sym|
|
69
|
-
|
104
|
+
send("#{sym}_result_count") > 0
|
70
105
|
end
|
71
106
|
end
|
72
107
|
|
data/lib/assert/context.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert/actual_value"
|
2
4
|
require "assert/assertions"
|
3
5
|
require "assert/context/let_dsl"
|
@@ -13,8 +15,13 @@ require "assert/suite"
|
|
13
15
|
require "assert/utils"
|
14
16
|
|
15
17
|
module Assert
|
18
|
+
# A Context is a scope for tests to run in. Contexts have setup and teardown
|
19
|
+
# blocks, subjects, and descriptions. Tests are run in the scope of a Context
|
20
|
+
# instance. Therefore, a Context should have minimal base
|
21
|
+
# logic/methods/instance_vars. The instance should remain pure to not pollute
|
22
|
+
# test scopes.
|
16
23
|
class Context
|
17
|
-
#
|
24
|
+
# Put all logic in DSL methods to keep context instances pure.
|
18
25
|
extend SetupDSL
|
19
26
|
extend SubjectDSL
|
20
27
|
extend SuiteDSL
|
@@ -24,33 +31,6 @@ module Assert
|
|
24
31
|
include Assert::Assertions
|
25
32
|
include Assert::Macros::Methods
|
26
33
|
|
27
|
-
# a Context is a scope for tests to run in. Contexts have setup and
|
28
|
-
# teardown blocks, subjects, and descriptions. Tests are run in the
|
29
|
-
# scope of a Context instance. Therefore, a Context should have
|
30
|
-
# minimal base logic/methods/instance_vars. The instance should remain
|
31
|
-
# pure to not pollute test scopes.
|
32
|
-
|
33
|
-
# if a test method is added to a context manually (not using a context helper):
|
34
|
-
# capture any context info, build a test obj, and add it to the suite
|
35
|
-
def self.method_added(method_name)
|
36
|
-
if method_name.to_s =~ Suite::TEST_METHOD_REGEX
|
37
|
-
klass_method_name = "#{self}##{method_name}"
|
38
|
-
|
39
|
-
if self.suite.test_methods.include?(klass_method_name)
|
40
|
-
puts "WARNING: redefining "#{klass_method_name}""
|
41
|
-
puts " from: #{caller_locations(1,1)}"
|
42
|
-
else
|
43
|
-
self.suite.test_methods << klass_method_name
|
44
|
-
end
|
45
|
-
|
46
|
-
self.suite.on_test(Test.for_method(
|
47
|
-
method_name.to_s,
|
48
|
-
ContextInfo.new(self, nil, caller_locations(1,1)),
|
49
|
-
self.suite.config
|
50
|
-
))
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
34
|
def initialize(running_test, config, result_callback)
|
55
35
|
@__assert_running_test__ = running_test
|
56
36
|
@__assert_config__ = config
|
@@ -58,7 +38,7 @@ module Assert
|
|
58
38
|
@__assert_pending__ = 0
|
59
39
|
|
60
40
|
@__assert_result_callback__ = proc do |result|
|
61
|
-
|
41
|
+
unless @__assert_with_bt__.empty?
|
62
42
|
result.set_with_bt(@__assert_with_bt__.dup)
|
63
43
|
end
|
64
44
|
result_callback.call(result)
|
@@ -83,7 +63,8 @@ module Assert
|
|
83
63
|
end
|
84
64
|
|
85
65
|
# The opposite of assert. Check if the result is false. If so, create a new
|
86
|
-
# pass result. Otherwise create a new fail result with the desc and
|
66
|
+
# pass result. Otherwise create a new fail result with the desc and
|
67
|
+
# fail msg.
|
87
68
|
def assert_not(assertion, fail_desc = nil)
|
88
69
|
assert(!assertion, fail_desc) do
|
89
70
|
"Failed assert_not: assertion was "\
|
@@ -92,8 +73,10 @@ module Assert
|
|
92
73
|
end
|
93
74
|
alias_method :refute, :assert_not
|
94
75
|
|
95
|
-
def assert_that(
|
96
|
-
|
76
|
+
def assert_that(
|
77
|
+
actual_value = Assert::ActualValue.not_given,
|
78
|
+
&actual_value_block)
|
79
|
+
Assert::ActualValue.new(actual_value, context: self, &actual_value_block)
|
97
80
|
end
|
98
81
|
|
99
82
|
# adds a Pass result to the end of the test's results
|
@@ -102,8 +85,10 @@ module Assert
|
|
102
85
|
if @__assert_pending__ == 0
|
103
86
|
capture_result(Assert::Result::Pass, pass_msg)
|
104
87
|
else
|
105
|
-
capture_result(
|
106
|
-
|
88
|
+
capture_result(
|
89
|
+
Assert::Result::Fail,
|
90
|
+
"Pending pass (make it not pending)",
|
91
|
+
)
|
107
92
|
end
|
108
93
|
end
|
109
94
|
|
@@ -122,12 +107,10 @@ module Assert
|
|
122
107
|
else
|
123
108
|
capture_result(Assert::Result::Fail, message || "")
|
124
109
|
end
|
110
|
+
elsif halt_on_fail?
|
111
|
+
raise Result::TestSkipped, "Pending fail: #{message || ""}"
|
125
112
|
else
|
126
|
-
|
127
|
-
raise Result::TestSkipped, "Pending fail: #{message || ""}"
|
128
|
-
else
|
129
|
-
capture_result(Assert::Result::Skip, "Pending fail: #{message || ""}")
|
130
|
-
end
|
113
|
+
capture_result(Assert::Result::Skip, "Pending fail: #{message || ""}")
|
131
114
|
end
|
132
115
|
end
|
133
116
|
alias_method :flunk, :fail
|
@@ -154,20 +137,23 @@ module Assert
|
|
154
137
|
begin
|
155
138
|
@__assert_with_bt__.push(bt.first)
|
156
139
|
instance_eval(&block)
|
157
|
-
rescue Result::TestSkipped, Result::TestFailure =>
|
158
|
-
if
|
159
|
-
|
140
|
+
rescue Result::TestSkipped, Result::TestFailure => ex
|
141
|
+
if ex.assert_with_bt.nil? && !@__assert_with_bt__.empty?
|
142
|
+
ex.assert_with_bt = @__assert_with_bt__.dup
|
160
143
|
end
|
161
|
-
raise(
|
144
|
+
raise(ex)
|
162
145
|
ensure
|
163
146
|
@__assert_with_bt__.pop
|
164
147
|
end
|
165
148
|
end
|
166
149
|
|
167
150
|
def subject
|
168
|
-
|
169
|
-
|
151
|
+
unless instance_variable_defined?("@__assert_subject__")
|
152
|
+
@__assert_subject__ =
|
153
|
+
instance_eval(&self.class.subject) if self.class.subject
|
170
154
|
end
|
155
|
+
|
156
|
+
@__assert_subject__
|
171
157
|
end
|
172
158
|
|
173
159
|
def inspect
|
@@ -190,12 +176,10 @@ module Assert
|
|
190
176
|
|
191
177
|
def capture_result(result_klass, msg)
|
192
178
|
@__assert_result_callback__.call(
|
193
|
-
result_klass.for_test(@__assert_running_test__, msg, caller_locations)
|
179
|
+
result_klass.for_test(@__assert_running_test__, msg, caller_locations),
|
194
180
|
)
|
195
181
|
end
|
196
182
|
|
197
|
-
|
198
|
-
@__assert_config__
|
199
|
-
end
|
183
|
+
attr_reader :__assert_config__
|
200
184
|
end
|
201
185
|
end
|