assert 2.12.2 → 2.13.0
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 +7 -0
- data/Gemfile +1 -6
- data/README.md +25 -6
- data/lib/assert/cli.rb +5 -2
- data/lib/assert/config.rb +2 -1
- data/lib/assert/context/subject_dsl.rb +1 -3
- data/lib/assert/file_line.rb +25 -0
- data/lib/assert/macros/methods.rb +6 -6
- data/lib/assert/runner.rb +16 -11
- data/lib/assert/test.rb +17 -12
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view/base.rb +22 -19
- data/lib/assert/view/default_view.rb +45 -19
- data/lib/assert/view/helpers/common.rb +8 -2
- data/test/support/factory.rb +3 -1
- data/test/unit/config_tests.rb +2 -1
- data/test/unit/file_line_tests.rb +54 -0
- data/test/unit/test_tests.rb +17 -8
- data/test/unit/view_tests.rb +3 -1
- metadata +40 -56
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cb4aa7ad09c0655c7575c8cd7b65d7477a4074bf
|
4
|
+
data.tar.gz: 7baa88b16be41c504944626e5d29e1a51d0c7502
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 900bfce4dbbda0860cd97d2719be1e9d0e7151fefb93d9f8190c4e3537f65d36fe1359e8df7e829208c69c698b272dfcc5991baa5d097d42d90c6595b2e75746
|
7
|
+
data.tar.gz: 02c7a331e37799de0e8a74f2885aa935bc9a59a4f0af300f66927ec05d408cfe6e822682d63a6116fdfdfc0e7bc946d32fee10ee3bf721deca257b2b03a3a67a
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -216,7 +216,7 @@ end
|
|
216
216
|
Using the CLI:
|
217
217
|
|
218
218
|
```sh
|
219
|
-
$ assert [-s|--seed] 1234
|
219
|
+
$ assert [-s|--runner-seed] 1234
|
220
220
|
```
|
221
221
|
|
222
222
|
Using an ENV var:
|
@@ -225,6 +225,24 @@ Using an ENV var:
|
|
225
225
|
$ ASSERT_RUNNER_SEED=1234 assert
|
226
226
|
```
|
227
227
|
|
228
|
+
### Verbose Output
|
229
|
+
|
230
|
+
By default, Assert shows terse runtime test result information. It provides a setting to turn on/off more verbose information:
|
231
|
+
|
232
|
+
In user/local settings file:
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
Assert.configure do |config|
|
236
|
+
config.verbose true
|
237
|
+
end
|
238
|
+
```
|
239
|
+
|
240
|
+
Using the CLI:
|
241
|
+
|
242
|
+
```sh
|
243
|
+
$ assert [-v|--verbose|--no-verbose]
|
244
|
+
```
|
245
|
+
|
228
246
|
### Capture Output
|
229
247
|
|
230
248
|
By default, Assert shows any output on `$stdout` produced while running a test. It provides a setting to override whether to show this output or to 'capture' it and display it in the test result details:
|
@@ -258,7 +276,7 @@ end
|
|
258
276
|
Using the CLI:
|
259
277
|
|
260
278
|
```sh
|
261
|
-
$ assert [-
|
279
|
+
$ assert [-h|--halt-on-fail|--no-halt-on-fail]
|
262
280
|
```
|
263
281
|
|
264
282
|
### Changed Only
|
@@ -306,10 +324,10 @@ If you just want to disable this feature completely:
|
|
306
324
|
Assert.configure do |config|
|
307
325
|
|
308
326
|
# run nothing if the `-c` flag is given
|
309
|
-
config.changed_proc Proc.new{ |test_paths| [] }
|
327
|
+
config.changed_proc Proc.new{ |config, test_paths| [] }
|
310
328
|
|
311
329
|
# run all test paths if the `-c` flag is given
|
312
|
-
config.changed_proc Proc.new{ |test_paths| test_paths }
|
330
|
+
config.changed_proc Proc.new{ |config, test_paths| test_paths }
|
313
331
|
|
314
332
|
end
|
315
333
|
```
|
@@ -425,7 +443,7 @@ Assert.configure do |config|
|
|
425
443
|
end
|
426
444
|
```
|
427
445
|
|
428
|
-
However, the view
|
446
|
+
However, the view handler you use is itself configurable. Define you own view handler class and specify it in your user/local settings:
|
429
447
|
|
430
448
|
```ruby
|
431
449
|
class MyCustomView < Assert::View::Base
|
@@ -445,13 +463,14 @@ Each view should implement the callback handler methods to output information at
|
|
445
463
|
|
446
464
|
Available callbacks from the runner, and when they are called:
|
447
465
|
|
448
|
-
* `before_load`: at the beginning, before the suite is loaded
|
466
|
+
* `before_load`: at the beginning, before the suite is loaded, the test files are passed as an arg
|
449
467
|
* `after_load`: after the suite is loaded, just before `on_start`
|
450
468
|
* `on_start`: when a loaded test suite starts running
|
451
469
|
* `before_test`: before a test starts running, the test is passed as an arg
|
452
470
|
* `on_result`: when a running tests generates a result, the result is passed as an arg
|
453
471
|
* `after_test`: after a test finishes running, the test is passed as an arg
|
454
472
|
* `on_finish`: when the test suite is finished running
|
473
|
+
* `on_interrupt`: called when the test suite is interrupted while running
|
455
474
|
|
456
475
|
Beyond that, each view can do as it sees fit. Initialize how you wish, take whatever settings you'd like, and output results as you see fit, given the available callbacks.
|
457
476
|
|
data/lib/assert/cli.rb
CHANGED
@@ -34,7 +34,7 @@ module Assert
|
|
34
34
|
:abbrev => 'o'
|
35
35
|
}
|
36
36
|
option 'halt_on_fail', 'halt a test when it fails', {
|
37
|
-
:abbrev => '
|
37
|
+
:abbrev => 'h'
|
38
38
|
}
|
39
39
|
option 'changed_only', 'only run test files with changes', {
|
40
40
|
:abbrev => 'c'
|
@@ -45,6 +45,9 @@ module Assert
|
|
45
45
|
option 'profile', 'output test profile info', {
|
46
46
|
:abbrev => 'e'
|
47
47
|
}
|
48
|
+
option 'verbose', 'output verbose runtime test info', {
|
49
|
+
:abbrev => 'v'
|
50
|
+
}
|
48
51
|
# show loaded test files, cli err backtraces, etc
|
49
52
|
option 'debug', 'run in debug mode'
|
50
53
|
end
|
@@ -62,7 +65,7 @@ module Assert
|
|
62
65
|
puts "#{exception.message}\n\n"
|
63
66
|
puts Assert.config.debug ? exception.backtrace.join("\n") : help
|
64
67
|
exit(1)
|
65
|
-
rescue
|
68
|
+
rescue StandardError => exception
|
66
69
|
puts "#{exception.class}: #{exception.message}"
|
67
70
|
puts exception.backtrace.join("\n")
|
68
71
|
exit(1)
|
data/lib/assert/config.rb
CHANGED
@@ -17,7 +17,7 @@ module Assert
|
|
17
17
|
settings :test_dir, :test_helper, :test_file_suffixes, :runner_seed
|
18
18
|
settings :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
|
19
19
|
settings :capture_output, :halt_on_fail, :changed_only, :pp_objects
|
20
|
-
settings :debug, :profile
|
20
|
+
settings :debug, :profile, :verbose
|
21
21
|
|
22
22
|
def initialize(settings = nil)
|
23
23
|
@suite = Assert::Suite.new(self)
|
@@ -41,6 +41,7 @@ module Assert
|
|
41
41
|
@pp_objects = false
|
42
42
|
@debug = false
|
43
43
|
@profile = false
|
44
|
+
@verbose = false
|
44
45
|
|
45
46
|
self.apply(settings || {})
|
46
47
|
end
|
@@ -10,9 +10,7 @@ class Assert::Context
|
|
10
10
|
else
|
11
11
|
parent = self.superclass.desc if self.superclass.respond_to?(:desc)
|
12
12
|
own = self.descriptions
|
13
|
-
[parent, *own].compact.reject
|
14
|
-
p.to_s.empty?
|
15
|
-
end.join(" ")
|
13
|
+
[parent, *own].compact.reject(&:empty?).join(" ")
|
16
14
|
end
|
17
15
|
end
|
18
16
|
alias_method :desc, :description
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Assert
|
2
|
+
|
3
|
+
class FileLine
|
4
|
+
|
5
|
+
def self.parse(file_line_path)
|
6
|
+
self.new(*file_line_path.match(/(.+)\:(.+)/)[1..2])
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :file, :line
|
10
|
+
|
11
|
+
def initialize(file, line)
|
12
|
+
@file, @line = file.to_s, line.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
"#{self.file}:#{self.line}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def ==(other_file_line)
|
20
|
+
self.file == other_file_line.file && self.line == other_file_line.line
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -13,7 +13,7 @@ module Assert::Macros
|
|
13
13
|
called_from = (methods.last.kind_of?(Array) ? methods.pop : caller).first
|
14
14
|
Assert::Macro.new do
|
15
15
|
methods.each{ |m| _methods_macro_instance_methods << [m, called_from] }
|
16
|
-
_methods_macro_test
|
16
|
+
_methods_macro_test called_from
|
17
17
|
end
|
18
18
|
end
|
19
19
|
alias_method :have_instance_methods, :have_instance_method
|
@@ -24,7 +24,7 @@ module Assert::Macros
|
|
24
24
|
called_from = (methods.last.kind_of?(Array) ? methods.pop : caller).first
|
25
25
|
Assert::Macro.new do
|
26
26
|
methods.each{ |m| _methods_macro_not_instance_methods << [m, called_from] }
|
27
|
-
_methods_macro_test
|
27
|
+
_methods_macro_test called_from
|
28
28
|
end
|
29
29
|
end
|
30
30
|
alias_method :not_have_instance_methods, :not_have_instance_method
|
@@ -35,7 +35,7 @@ module Assert::Macros
|
|
35
35
|
called_from = (methods.last.kind_of?(Array) ? methods.pop : caller).first
|
36
36
|
Assert::Macro.new do
|
37
37
|
methods.each{ |m| _methods_macro_class_methods << [m, called_from] }
|
38
|
-
_methods_macro_test
|
38
|
+
_methods_macro_test called_from
|
39
39
|
end
|
40
40
|
end
|
41
41
|
alias_method :have_class_methods, :have_class_method
|
@@ -46,7 +46,7 @@ module Assert::Macros
|
|
46
46
|
called_from = (methods.last.kind_of?(Array) ? methods.pop : caller).first
|
47
47
|
Assert::Macro.new do
|
48
48
|
methods.each{ |m| _methods_macro_not_class_methods << [m, called_from] }
|
49
|
-
_methods_macro_test
|
49
|
+
_methods_macro_test called_from
|
50
50
|
end
|
51
51
|
end
|
52
52
|
alias_method :not_have_class_methods, :not_have_class_method
|
@@ -99,8 +99,8 @@ module Assert::Macros
|
|
99
99
|
|
100
100
|
# private
|
101
101
|
|
102
|
-
def _methods_macro_test
|
103
|
-
@_methods_macro_test ||= should "respond to methods" do
|
102
|
+
def _methods_macro_test(called_from)
|
103
|
+
@_methods_macro_test ||= should "respond to methods", called_from do
|
104
104
|
|
105
105
|
self.class._methods_macro_instance_methods.each do |(method, called_from)|
|
106
106
|
msg = "#{subject.class.name} does not have instance method ##{method}"
|
data/lib/assert/runner.rb
CHANGED
@@ -12,25 +12,30 @@ module Assert
|
|
12
12
|
|
13
13
|
def run(suite, view)
|
14
14
|
raise ArgumentError if !suite.kind_of?(Suite)
|
15
|
-
|
16
15
|
view.fire(:on_start)
|
17
|
-
suite.setup
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
begin
|
18
|
+
suite.setup
|
19
|
+
|
20
|
+
suite.start_time = Time.now
|
21
|
+
tests_to_run(suite).each do |test|
|
22
|
+
view.fire(:before_test, test)
|
23
|
+
test.run{ |result| view.fire(:on_result, result) }
|
24
|
+
view.fire(:after_test, test)
|
25
|
+
end
|
26
|
+
suite.end_time = Time.now
|
27
|
+
|
28
|
+
suite.teardown
|
29
|
+
rescue Interrupt => err
|
30
|
+
view.fire(:on_interrupt, err)
|
31
|
+
raise(err)
|
24
32
|
end
|
25
|
-
suite.end_time = Time.now
|
26
33
|
|
27
|
-
suite.teardown
|
28
34
|
view.fire(:on_finish)
|
29
|
-
|
30
35
|
suite.count(:failed) + suite.count(:errored)
|
31
36
|
end
|
32
37
|
|
33
|
-
|
38
|
+
private
|
34
39
|
|
35
40
|
def tests_to_run(suite)
|
36
41
|
srand self.config.runner_seed
|
data/lib/assert/test.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'stringio'
|
2
|
+
require 'assert/file_line'
|
2
3
|
require 'assert/result'
|
3
4
|
|
4
5
|
module Assert
|
6
|
+
|
5
7
|
class Test
|
6
8
|
|
7
9
|
# a Test is some code/method to run in the scope of a Context. After a
|
8
10
|
# a test runs, it should have some assertions which are its results.
|
9
11
|
|
10
|
-
attr_reader :
|
12
|
+
attr_reader :context_info, :config
|
13
|
+
attr_reader :name, :file_line, :code
|
11
14
|
attr_accessor :results, :output, :run_time
|
12
15
|
|
13
16
|
def initialize(name, suite_ci, config, opts = nil, &block)
|
14
17
|
@context_info = suite_ci
|
15
|
-
@
|
18
|
+
@config = config
|
19
|
+
@name, @file_line = name_file_line_from_context(@context_info, name)
|
16
20
|
|
17
21
|
o = opts || {}
|
18
22
|
@code = o[:code] || block || Proc.new{}
|
@@ -23,9 +27,9 @@ module Assert
|
|
23
27
|
@result_rate = 0
|
24
28
|
end
|
25
29
|
|
26
|
-
def context_class
|
27
|
-
|
28
|
-
end
|
30
|
+
def context_class; self.context_info.klass; end
|
31
|
+
def file; self.file_line.file; end
|
32
|
+
def line_number; self.file_line.line; end
|
29
33
|
|
30
34
|
def run(&result_callback)
|
31
35
|
@results = Result::Set.new(result_callback)
|
@@ -69,7 +73,7 @@ module Assert
|
|
69
73
|
"#<#{self.class}:#{'0x0%x' % (object_id << 1)} #{attributes_string}>"
|
70
74
|
end
|
71
75
|
|
72
|
-
|
76
|
+
private
|
73
77
|
|
74
78
|
def run_test_main(scope)
|
75
79
|
begin
|
@@ -137,17 +141,18 @@ module Assert
|
|
137
141
|
StringIO.new(@output, "a+")
|
138
142
|
end
|
139
143
|
|
140
|
-
def
|
141
|
-
[
|
142
|
-
|
143
|
-
|
144
|
+
def name_file_line_from_context(context_info, name)
|
145
|
+
[ [ context_info.klass.description,
|
146
|
+
name
|
147
|
+
].compact.reject(&:empty?).join(" "),
|
148
|
+
FileLine.parse(context_info.called_from)
|
149
|
+
]
|
144
150
|
end
|
145
151
|
|
146
|
-
private
|
147
|
-
|
148
152
|
def get_rate(count, time)
|
149
153
|
time == 0 ? 0.0 : (count.to_f / time.to_f)
|
150
154
|
end
|
151
155
|
|
152
156
|
end
|
157
|
+
|
153
158
|
end
|
data/lib/assert/version.rb
CHANGED
data/lib/assert/view/base.rb
CHANGED
@@ -58,25 +58,28 @@ module Assert::View
|
|
58
58
|
# and sent to the io stream.
|
59
59
|
|
60
60
|
# available callbacks from the runner:
|
61
|
-
# * `before_load`:
|
62
|
-
# * `after_load`:
|
63
|
-
#
|
64
|
-
# * `on_start`:
|
65
|
-
# * `before_test`:
|
66
|
-
#
|
67
|
-
# * `on_result`:
|
68
|
-
#
|
69
|
-
# * `after_test`:
|
70
|
-
#
|
71
|
-
# * `on_finish`:
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def
|
76
|
-
def
|
77
|
-
def
|
78
|
-
def
|
79
|
-
def
|
61
|
+
# * `before_load`: called at the beginning, before the suite is loaded
|
62
|
+
# * `after_load`: called after the suite is loaded, just before `on_start`
|
63
|
+
# functionally equivalent to `on_start`
|
64
|
+
# * `on_start`: called when a loaded test suite starts running
|
65
|
+
# * `before_test`: called before a test starts running
|
66
|
+
# the test is passed as an arg
|
67
|
+
# * `on_result`: called when a running tests generates a result
|
68
|
+
# the result is passed as an arg
|
69
|
+
# * `after_test`: called after a test finishes running
|
70
|
+
# the test is passed as an arg
|
71
|
+
# * `on_finish`: called when the test suite is finished running
|
72
|
+
# * `on_interrupt`: called when the test suite is interrupted while running
|
73
|
+
# the interrupt exception is passed as an arg
|
74
|
+
|
75
|
+
def before_load(test_files); end
|
76
|
+
def after_load; end
|
77
|
+
def on_start; end
|
78
|
+
def before_test(test); end
|
79
|
+
def on_result(result); end
|
80
|
+
def after_test(test); end
|
81
|
+
def on_finish; end
|
82
|
+
def on_interrupt(err); end
|
80
83
|
|
81
84
|
# IO capture
|
82
85
|
|
@@ -31,6 +31,14 @@ module Assert::View
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def before_test(test)
|
35
|
+
if show_test_verbose_info?
|
36
|
+
puts "#{test.name.inspect} (#{test.context_class})"
|
37
|
+
puts " #{test.file_line}"
|
38
|
+
print " "
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
def on_result(result)
|
35
43
|
result_abbrev = self.send("#{result.to_sym}_abbrev")
|
36
44
|
styled_abbrev = ansi_styled_msg(result_abbrev, result_ansi_styles(result))
|
@@ -38,27 +46,17 @@ module Assert::View
|
|
38
46
|
print styled_abbrev
|
39
47
|
end
|
40
48
|
|
49
|
+
def after_test(test)
|
50
|
+
if show_test_verbose_info?
|
51
|
+
print " #{test_run_time(test)} seconds,"\
|
52
|
+
" #{test.result_count} results,"\
|
53
|
+
" #{test_result_rate(test)} results/s\n"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
41
57
|
def on_finish
|
42
58
|
if tests?
|
43
|
-
|
44
|
-
puts
|
45
|
-
|
46
|
-
# output detailed results for the tests in reverse test/result order
|
47
|
-
tests = suite.ordered_tests.reverse
|
48
|
-
result_details_for(tests, :reversed).each do |details|
|
49
|
-
if show_result_details?(details.result)
|
50
|
-
# output the styled result details
|
51
|
-
result = details.result
|
52
|
-
puts ansi_styled_msg(result.to_s, result_ansi_styles(result))
|
53
|
-
|
54
|
-
# output any captured stdout
|
55
|
-
output = details.output
|
56
|
-
puts captured_output(output) if output && !output.empty?
|
57
|
-
|
58
|
-
# add an empty line between each result detail
|
59
|
-
puts
|
60
|
-
end
|
61
|
-
end
|
59
|
+
dump_test_results
|
62
60
|
end
|
63
61
|
|
64
62
|
# show profile output
|
@@ -82,6 +80,34 @@ module Assert::View
|
|
82
80
|
puts "(#{run_time} seconds, #{test_rate} tests/s, #{result_rate} results/s)"
|
83
81
|
end
|
84
82
|
|
83
|
+
def on_interrupt(err)
|
84
|
+
dump_test_results
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def dump_test_results
|
90
|
+
print "\n"
|
91
|
+
puts
|
92
|
+
|
93
|
+
# output detailed results for the tests in reverse test/result order
|
94
|
+
tests = suite.ordered_tests.reverse
|
95
|
+
result_details_for(tests, :reversed).each do |details|
|
96
|
+
if show_result_details?(details.result)
|
97
|
+
# output the styled result details
|
98
|
+
result = details.result
|
99
|
+
puts ansi_styled_msg(result.to_s, result_ansi_styles(result))
|
100
|
+
|
101
|
+
# output any captured stdout
|
102
|
+
output = details.output
|
103
|
+
puts captured_output(output) if output && !output.empty?
|
104
|
+
|
105
|
+
# add an empty line between each result detail
|
106
|
+
puts
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
85
111
|
end
|
86
112
|
|
87
113
|
end
|
@@ -77,8 +77,12 @@ module Assert::View::Helpers
|
|
77
77
|
!!config.profile
|
78
78
|
end
|
79
79
|
|
80
|
+
def show_test_verbose_info?
|
81
|
+
!!config.verbose
|
82
|
+
end
|
83
|
+
|
80
84
|
# get all the result details for a set of tests
|
81
|
-
def result_details_for(tests, result_order
|
85
|
+
def result_details_for(tests, result_order = :normal)
|
82
86
|
test_index = 0
|
83
87
|
tests.collect do |test|
|
84
88
|
test_index += 1
|
@@ -92,7 +96,7 @@ module Assert::View::Helpers
|
|
92
96
|
end
|
93
97
|
|
94
98
|
# get all the result details for a set of tests matching a file or context
|
95
|
-
def matched_result_details_for(match, tests, result_order
|
99
|
+
def matched_result_details_for(match, tests, result_order = :normal)
|
96
100
|
context_match = match.kind_of?(Class) && match.ancestors.include?(Assert::Context)
|
97
101
|
file_match = match.kind_of?(String)
|
98
102
|
|
@@ -187,6 +191,7 @@ module Assert::View::Helpers
|
|
187
191
|
end
|
188
192
|
|
189
193
|
module ClassMethods
|
194
|
+
|
190
195
|
def option(name, *default_vals)
|
191
196
|
default = default_vals.size > 1 ? default_vals : default_vals.first
|
192
197
|
define_method(name) do |*args|
|
@@ -196,6 +201,7 @@ module Assert::View::Helpers
|
|
196
201
|
(val = instance_variable_get("@#{name}")).nil? ? default : val
|
197
202
|
end
|
198
203
|
end
|
204
|
+
|
199
205
|
end
|
200
206
|
|
201
207
|
end
|
data/test/support/factory.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'assert/config'
|
2
|
+
require 'assert/factory'
|
2
3
|
require 'assert/result'
|
3
4
|
require 'assert/suite'
|
4
5
|
require 'assert/test'
|
5
6
|
|
6
7
|
module Factory
|
8
|
+
extend Assert::Factory
|
7
9
|
|
8
10
|
def self.context_info_called_from
|
9
|
-
"
|
11
|
+
"#{Factory.path}_tests.rb:#{Factory.integer}"
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.context_info(context_klass = nil)
|
data/test/unit/config_tests.rb
CHANGED
@@ -14,7 +14,7 @@ class Assert::Config
|
|
14
14
|
should have_imeths :test_dir, :test_helper, :test_file_suffixes, :runner_seed
|
15
15
|
should have_imeths :changed_proc, :pp_proc, :use_diff_proc, :run_diff_proc
|
16
16
|
should have_imeths :capture_output, :halt_on_fail, :changed_only, :pp_objects
|
17
|
-
should have_imeths :debug, :profile
|
17
|
+
should have_imeths :debug, :profile, :verbose
|
18
18
|
should have_imeths :apply
|
19
19
|
|
20
20
|
should "default the view, suite, and runner" do
|
@@ -44,6 +44,7 @@ class Assert::Config
|
|
44
44
|
assert_not subject.pp_objects
|
45
45
|
assert_not subject.debug
|
46
46
|
assert_not subject.profile
|
47
|
+
assert_not subject.verbose
|
47
48
|
end
|
48
49
|
|
49
50
|
should "apply settings given from a hash" do
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'assert'
|
2
|
+
require 'assert/file_line'
|
3
|
+
|
4
|
+
class Assert::FileLine
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Assert::FileLine"
|
8
|
+
setup do
|
9
|
+
@file = "#{Factory.path}_tests.rb"
|
10
|
+
@line = Factory.integer.to_s
|
11
|
+
end
|
12
|
+
subject{ Assert::FileLine }
|
13
|
+
|
14
|
+
should have_imeths :parse
|
15
|
+
|
16
|
+
should "know how to parse and init from a file line path string" do
|
17
|
+
file_line_path = "#{@file}:#{@line}"
|
18
|
+
file_line = subject.parse(file_line_path)
|
19
|
+
|
20
|
+
assert_equal @file, file_line.file
|
21
|
+
assert_equal @line, file_line.line
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class InitTests < UnitTests
|
27
|
+
desc "when init"
|
28
|
+
setup do
|
29
|
+
@file_line = Assert::FileLine.new(@file, @line)
|
30
|
+
end
|
31
|
+
subject{ @file_line }
|
32
|
+
|
33
|
+
should have_readers :file, :line
|
34
|
+
|
35
|
+
should "know its file and line" do
|
36
|
+
assert_equal @file, subject.file
|
37
|
+
assert_equal @line, subject.line
|
38
|
+
end
|
39
|
+
|
40
|
+
should "know its string representation" do
|
41
|
+
assert_equal "#{subject.file}:#{subject.line}", subject.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
should "know if it is equal to another file line" do
|
45
|
+
yes = Assert::FileLine.new(@file, @line)
|
46
|
+
no = Assert::FileLine.new("#{Factory.path}_tests.rb", Factory.integer.to_s)
|
47
|
+
|
48
|
+
assert_equal yes, subject
|
49
|
+
assert_not_equal no, subject
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/test/unit/test_tests.rb
CHANGED
@@ -2,6 +2,7 @@ require 'assert'
|
|
2
2
|
require 'assert/test'
|
3
3
|
|
4
4
|
require 'assert/config'
|
5
|
+
require 'assert/file_line'
|
5
6
|
|
6
7
|
class Assert::Test
|
7
8
|
|
@@ -15,17 +16,14 @@ class Assert::Test
|
|
15
16
|
end
|
16
17
|
subject{ @test }
|
17
18
|
|
18
|
-
should have_readers :
|
19
|
+
should have_readers :context_info, :config
|
20
|
+
should have_readers :name, :file_line, :code
|
19
21
|
should have_accessors :results, :output, :run_time
|
20
|
-
should have_imeths :
|
22
|
+
should have_imeths :context_class, :file, :line_number
|
23
|
+
should have_imeths :run, :result_count, :result_rate
|
21
24
|
should have_imeths *Assert::Result.types.keys.collect{ |k| "#{k}_results" }
|
22
25
|
|
23
|
-
should "
|
24
|
-
exp_name = "context class should do something amazing"
|
25
|
-
assert_equal exp_name, subject.name
|
26
|
-
end
|
27
|
-
|
28
|
-
should "know it's context class" do
|
26
|
+
should "know its context class" do
|
29
27
|
assert_equal @context_class, subject.context_class
|
30
28
|
end
|
31
29
|
|
@@ -34,6 +32,17 @@ class Assert::Test
|
|
34
32
|
assert_equal cust_config, Factory.test(cust_config).config
|
35
33
|
end
|
36
34
|
|
35
|
+
should "know its name, file line, file and number" do
|
36
|
+
exp = "context class should do something amazing"
|
37
|
+
assert_equal exp, subject.name
|
38
|
+
|
39
|
+
exp = Assert::FileLine.new(*@context_info.called_from.split(':'))
|
40
|
+
assert_equal exp, subject.file_line
|
41
|
+
|
42
|
+
assert_equal subject.file_line.file, subject.file
|
43
|
+
assert_equal subject.file_line.line, subject.line_number
|
44
|
+
end
|
45
|
+
|
37
46
|
should "get its code from any passed opt, falling back on any given block" do
|
38
47
|
assert_equal @test_code, subject.code
|
39
48
|
|
data/test/unit/view_tests.rb
CHANGED
@@ -16,7 +16,8 @@ class Assert::View::Base
|
|
16
16
|
|
17
17
|
# accessors, base methods
|
18
18
|
should have_imeths :is_tty?, :view, :config, :suite, :fire
|
19
|
-
should have_imeths :before_load, :after_load
|
19
|
+
should have_imeths :before_load, :after_load
|
20
|
+
should have_imeths :on_start, :on_finish, :on_interrupt
|
20
21
|
should have_imeths :before_test, :after_test, :on_result
|
21
22
|
|
22
23
|
# common methods
|
@@ -26,6 +27,7 @@ class Assert::View::Base
|
|
26
27
|
should have_imeths :suite_contexts, :ordered_suite_contexts
|
27
28
|
should have_imeths :suite_files, :ordered_suite_files
|
28
29
|
should have_imeths :ordered_profile_tests, :show_test_profile_info?
|
30
|
+
should have_imeths :show_test_verbose_info?
|
29
31
|
should have_imeths :result_details_for, :matched_result_details_for, :show_result_details?
|
30
32
|
should have_imeths :ocurring_result_types, :result_summary_msg
|
31
33
|
should have_imeths :all_pass_result_summary_msg, :results_summary_sentence
|
metadata
CHANGED
@@ -1,51 +1,41 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 12
|
9
|
-
- 2
|
10
|
-
version: 2.12.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.13.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Kelly Redding
|
14
8
|
- Collin Redding
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 9
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 3
|
31
|
-
version: "1.3"
|
32
|
-
version_requirements: *id001
|
33
|
-
type: :runtime
|
12
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
34
15
|
name: ansi
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :runtime
|
35
22
|
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
36
28
|
description: Test::Unit style testing framework, just better than Test::Unit.
|
37
|
-
email:
|
29
|
+
email:
|
38
30
|
- kelly@kellyredding.com
|
39
31
|
- collin.redding@me.com
|
40
|
-
executables:
|
32
|
+
executables:
|
41
33
|
- assert
|
42
34
|
extensions: []
|
43
|
-
|
44
35
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
|
47
|
-
- .
|
48
|
-
- .gitignore
|
36
|
+
files:
|
37
|
+
- ".assert.rb"
|
38
|
+
- ".gitignore"
|
49
39
|
- Gemfile
|
50
40
|
- LICENSE.txt
|
51
41
|
- README.md
|
@@ -63,6 +53,7 @@ files:
|
|
63
53
|
- lib/assert/context/suite_dsl.rb
|
64
54
|
- lib/assert/context/test_dsl.rb
|
65
55
|
- lib/assert/factory.rb
|
56
|
+
- lib/assert/file_line.rb
|
66
57
|
- lib/assert/macro.rb
|
67
58
|
- lib/assert/macros/methods.rb
|
68
59
|
- lib/assert/result.rb
|
@@ -107,6 +98,7 @@ files:
|
|
107
98
|
- test/unit/context/test_dsl_tests.rb
|
108
99
|
- test/unit/context_tests.rb
|
109
100
|
- test/unit/factory_tests.rb
|
101
|
+
- test/unit/file_line_tests.rb
|
110
102
|
- test/unit/macro_tests.rb
|
111
103
|
- test/unit/result_tests.rb
|
112
104
|
- test/unit/runner_tests.rb
|
@@ -117,39 +109,30 @@ files:
|
|
117
109
|
- test/unit/view_tests.rb
|
118
110
|
- tmp/.gitkeep
|
119
111
|
homepage: http://github.com/redding/assert
|
120
|
-
licenses:
|
112
|
+
licenses:
|
121
113
|
- MIT
|
114
|
+
metadata: {}
|
122
115
|
post_install_message:
|
123
116
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
117
|
+
require_paths:
|
126
118
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
-
|
129
|
-
requirements:
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
130
121
|
- - ">="
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
version: "0"
|
136
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
139
126
|
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
version: "0"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
145
129
|
requirements: []
|
146
|
-
|
147
130
|
rubyforge_project:
|
148
|
-
rubygems_version:
|
131
|
+
rubygems_version: 2.4.5
|
149
132
|
signing_key:
|
150
|
-
specification_version:
|
133
|
+
specification_version: 4
|
151
134
|
summary: Test::Unit style testing framework, just better than Test::Unit.
|
152
|
-
test_files:
|
135
|
+
test_files:
|
153
136
|
- test/helper.rb
|
154
137
|
- test/support/diff_a.txt
|
155
138
|
- test/support/diff_b.txt
|
@@ -179,6 +162,7 @@ test_files:
|
|
179
162
|
- test/unit/context/test_dsl_tests.rb
|
180
163
|
- test/unit/context_tests.rb
|
181
164
|
- test/unit/factory_tests.rb
|
165
|
+
- test/unit/file_line_tests.rb
|
182
166
|
- test/unit/macro_tests.rb
|
183
167
|
- test/unit/result_tests.rb
|
184
168
|
- test/unit/runner_tests.rb
|