assert 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/assert.gemspec +0 -2
- data/lib/assert/assert_runner.rb +1 -1
- data/lib/assert/assertions.rb +1 -1
- data/lib/assert/config.rb +6 -1
- data/lib/assert/config_helpers.rb +75 -0
- data/lib/assert/context.rb +20 -14
- data/lib/assert/context/test_dsl.rb +17 -13
- data/lib/assert/{view/default_view.rb → default_view.rb} +9 -17
- data/lib/assert/factory.rb +2 -7
- data/lib/assert/file_line.rb +7 -3
- data/lib/assert/macro.rb +1 -1
- data/lib/assert/macros/methods.rb +1 -1
- data/lib/assert/result.rb +84 -90
- data/lib/assert/runner.rb +8 -2
- data/lib/assert/suite.rb +15 -5
- data/lib/assert/test.rb +112 -75
- data/lib/assert/version.rb +1 -1
- data/lib/assert/view.rb +108 -21
- data/lib/assert/view_helpers.rb +238 -0
- data/test/support/factory.rb +23 -6
- data/test/system/test_tests.rb +359 -0
- data/test/unit/assertions_tests.rb +1 -1
- data/test/unit/config_helpers_tests.rb +95 -0
- data/test/unit/config_tests.rb +5 -1
- data/test/unit/context/test_dsl_tests.rb +25 -17
- data/test/unit/context_tests.rb +45 -10
- data/test/unit/factory_tests.rb +9 -11
- data/test/unit/file_line_tests.rb +22 -0
- data/test/unit/result_tests.rb +219 -160
- data/test/unit/runner_tests.rb +19 -5
- data/test/unit/suite_tests.rb +23 -4
- data/test/unit/test_tests.rb +167 -33
- data/test/unit/view_helpers_tests.rb +210 -0
- data/test/unit/view_tests.rb +66 -26
- metadata +12 -23
- data/lib/assert/view/base.rb +0 -91
- data/lib/assert/view/helpers/ansi_styles.rb +0 -25
- data/lib/assert/view/helpers/common.rb +0 -209
- data/test/system/running_tests.rb +0 -404
data/test/unit/view_tests.rb
CHANGED
@@ -1,38 +1,50 @@
|
|
1
1
|
require 'assert'
|
2
|
-
require 'assert/
|
3
|
-
|
2
|
+
require 'assert/view'
|
3
|
+
|
4
4
|
require 'stringio'
|
5
|
+
require 'assert/suite'
|
6
|
+
require 'assert/view_helpers'
|
5
7
|
|
6
|
-
|
8
|
+
module Assert::View
|
7
9
|
|
8
10
|
class UnitTests < Assert::Context
|
9
|
-
desc "Assert::View
|
11
|
+
desc "Assert::View"
|
12
|
+
subject { Assert::View }
|
13
|
+
|
14
|
+
should have_instance_method :require_user_view
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
class BaseTests < UnitTests
|
19
|
+
desc "Base"
|
10
20
|
setup do
|
11
|
-
@io
|
21
|
+
@io = StringIO.new("", "w+")
|
12
22
|
@config = Factory.modes_off_config
|
13
|
-
|
23
|
+
|
24
|
+
@view = Assert::View::Base.new(@config, @io)
|
14
25
|
end
|
15
26
|
subject{ @view }
|
16
27
|
|
17
|
-
|
18
|
-
should have_imeths :
|
28
|
+
should have_readers :config
|
29
|
+
should have_imeths :view, :is_tty?, :ansi_styled_msg
|
30
|
+
should have_imeths :fire
|
19
31
|
should have_imeths :before_load, :after_load
|
20
32
|
should have_imeths :on_start, :on_finish, :on_interrupt
|
21
33
|
should have_imeths :before_test, :after_test, :on_result
|
22
34
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
should
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
should "include the view helpers" do
|
36
|
+
assert_includes Assert::ViewHelpers, subject.class
|
37
|
+
end
|
38
|
+
|
39
|
+
should "default its style options" do
|
40
|
+
assert_false subject.styled
|
41
|
+
|
42
|
+
assert_nil subject.pass_styles
|
43
|
+
assert_nil subject.fail_styles
|
44
|
+
assert_nil subject.error_styles
|
45
|
+
assert_nil subject.skip_styles
|
46
|
+
assert_nil subject.ignore_styles
|
47
|
+
end
|
36
48
|
|
37
49
|
should "default its result abbreviations" do
|
38
50
|
assert_equal '.', subject.pass_abbrev
|
@@ -42,17 +54,45 @@ class Assert::View::Base
|
|
42
54
|
assert_equal 'E', subject.error_abbrev
|
43
55
|
end
|
44
56
|
|
57
|
+
should "know its config" do
|
58
|
+
assert_equal @config, subject.config
|
59
|
+
end
|
60
|
+
|
61
|
+
should "expose itself as `view`" do
|
62
|
+
assert_equal subject, subject.view
|
63
|
+
end
|
64
|
+
|
45
65
|
should "know if it is a tty" do
|
46
66
|
assert_equal !!@io.isatty, subject.is_tty?
|
47
67
|
end
|
48
68
|
|
49
|
-
|
69
|
+
should "know how to build ansi styled messages" do
|
70
|
+
msg = Factory.string
|
71
|
+
result = [:pass, :fail, :error, :skip, :ignore].choice
|
50
72
|
|
51
|
-
|
52
|
-
|
53
|
-
|
73
|
+
Assert.stub(subject, :is_tty?){ false }
|
74
|
+
Assert.stub(subject, :styled){ false }
|
75
|
+
assert_equal msg, subject.ansi_styled_msg(msg, result)
|
54
76
|
|
55
|
-
|
77
|
+
Assert.stub(subject, :is_tty?){ false }
|
78
|
+
Assert.stub(subject, :styled){ true }
|
79
|
+
assert_equal msg, subject.ansi_styled_msg(msg, result)
|
80
|
+
|
81
|
+
Assert.stub(subject, :is_tty?){ true }
|
82
|
+
Assert.stub(subject, :styled){ false }
|
83
|
+
assert_equal msg, subject.ansi_styled_msg(msg, result)
|
84
|
+
|
85
|
+
Assert.stub(subject, :is_tty?){ true }
|
86
|
+
Assert.stub(subject, :styled){ true }
|
87
|
+
Assert.stub(subject, "#{result}_styles"){ [] }
|
88
|
+
assert_equal msg, subject.ansi_styled_msg(msg, result)
|
89
|
+
|
90
|
+
styles = Factory.integer(3).times.map{ Assert::ViewHelpers::Ansi::CODES.keys.choice }
|
91
|
+
Assert.stub(subject, "#{result}_styles"){ styles }
|
92
|
+
exp_code = Assert::ViewHelpers::Ansi.code_for(*styles)
|
93
|
+
exp = exp_code + msg + Assert::ViewHelpers::Ansi.code_for(:reset)
|
94
|
+
assert_equal exp, subject.ansi_styled_msg(msg, result)
|
95
|
+
end
|
56
96
|
|
57
97
|
end
|
58
98
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: ansi
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.3'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.3'
|
12
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
28
14
|
description: Test::Unit style testing framework, just better than Test::Unit.
|
29
15
|
email:
|
30
16
|
- kelly@kellyredding.com
|
@@ -47,11 +33,13 @@ files:
|
|
47
33
|
- lib/assert/assertions.rb
|
48
34
|
- lib/assert/cli.rb
|
49
35
|
- lib/assert/config.rb
|
36
|
+
- lib/assert/config_helpers.rb
|
50
37
|
- lib/assert/context.rb
|
51
38
|
- lib/assert/context/setup_dsl.rb
|
52
39
|
- lib/assert/context/subject_dsl.rb
|
53
40
|
- lib/assert/context/suite_dsl.rb
|
54
41
|
- lib/assert/context/test_dsl.rb
|
42
|
+
- lib/assert/default_view.rb
|
55
43
|
- lib/assert/factory.rb
|
56
44
|
- lib/assert/file_line.rb
|
57
45
|
- lib/assert/macro.rb
|
@@ -64,18 +52,15 @@ files:
|
|
64
52
|
- lib/assert/utils.rb
|
65
53
|
- lib/assert/version.rb
|
66
54
|
- lib/assert/view.rb
|
67
|
-
- lib/assert/
|
68
|
-
- lib/assert/view/default_view.rb
|
69
|
-
- lib/assert/view/helpers/ansi_styles.rb
|
70
|
-
- lib/assert/view/helpers/common.rb
|
55
|
+
- lib/assert/view_helpers.rb
|
71
56
|
- log/.gitkeep
|
72
57
|
- test/helper.rb
|
73
58
|
- test/support/diff_a.txt
|
74
59
|
- test/support/diff_b.txt
|
75
60
|
- test/support/factory.rb
|
76
61
|
- test/support/inherited_stuff.rb
|
77
|
-
- test/system/running_tests.rb
|
78
62
|
- test/system/stub_tests.rb
|
63
|
+
- test/system/test_tests.rb
|
79
64
|
- test/unit/assert_tests.rb
|
80
65
|
- test/unit/assertions/assert_block_tests.rb
|
81
66
|
- test/unit/assertions/assert_empty_tests.rb
|
@@ -91,6 +76,7 @@ files:
|
|
91
76
|
- test/unit/assertions/assert_same_tests.rb
|
92
77
|
- test/unit/assertions/assert_true_false_tests.rb
|
93
78
|
- test/unit/assertions_tests.rb
|
79
|
+
- test/unit/config_helpers_tests.rb
|
94
80
|
- test/unit/config_tests.rb
|
95
81
|
- test/unit/context/setup_dsl_tests.rb
|
96
82
|
- test/unit/context/subject_dsl_tests.rb
|
@@ -106,6 +92,7 @@ files:
|
|
106
92
|
- test/unit/suite_tests.rb
|
107
93
|
- test/unit/test_tests.rb
|
108
94
|
- test/unit/utils_tests.rb
|
95
|
+
- test/unit/view_helpers_tests.rb
|
109
96
|
- test/unit/view_tests.rb
|
110
97
|
- tmp/.gitkeep
|
111
98
|
homepage: http://github.com/redding/assert
|
@@ -138,8 +125,8 @@ test_files:
|
|
138
125
|
- test/support/diff_b.txt
|
139
126
|
- test/support/factory.rb
|
140
127
|
- test/support/inherited_stuff.rb
|
141
|
-
- test/system/running_tests.rb
|
142
128
|
- test/system/stub_tests.rb
|
129
|
+
- test/system/test_tests.rb
|
143
130
|
- test/unit/assert_tests.rb
|
144
131
|
- test/unit/assertions/assert_block_tests.rb
|
145
132
|
- test/unit/assertions/assert_empty_tests.rb
|
@@ -155,6 +142,7 @@ test_files:
|
|
155
142
|
- test/unit/assertions/assert_same_tests.rb
|
156
143
|
- test/unit/assertions/assert_true_false_tests.rb
|
157
144
|
- test/unit/assertions_tests.rb
|
145
|
+
- test/unit/config_helpers_tests.rb
|
158
146
|
- test/unit/config_tests.rb
|
159
147
|
- test/unit/context/setup_dsl_tests.rb
|
160
148
|
- test/unit/context/subject_dsl_tests.rb
|
@@ -170,4 +158,5 @@ test_files:
|
|
170
158
|
- test/unit/suite_tests.rb
|
171
159
|
- test/unit/test_tests.rb
|
172
160
|
- test/unit/utils_tests.rb
|
161
|
+
- test/unit/view_helpers_tests.rb
|
173
162
|
- test/unit/view_tests.rb
|
data/lib/assert/view/base.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'assert/config'
|
2
|
-
require 'assert/suite'
|
3
|
-
require 'assert/result'
|
4
|
-
|
5
|
-
module Assert::View
|
6
|
-
|
7
|
-
class Base
|
8
|
-
|
9
|
-
# include a bunch of common helper methods
|
10
|
-
|
11
|
-
require 'assert/view/helpers/common'
|
12
|
-
include Helpers::Common
|
13
|
-
|
14
|
-
# setup options and their default values
|
15
|
-
|
16
|
-
option 'pass_abbrev', '.'
|
17
|
-
option 'fail_abbrev', 'F'
|
18
|
-
option 'ignore_abbrev', 'I'
|
19
|
-
option 'skip_abbrev', 'S'
|
20
|
-
option 'error_abbrev', 'E'
|
21
|
-
|
22
|
-
attr_reader :config, :suite
|
23
|
-
|
24
|
-
def initialize(output_io, *args)
|
25
|
-
@output_io = output_io
|
26
|
-
@suite, @config = [
|
27
|
-
args.last.kind_of?(Assert::Suite) ? args.pop : nil,
|
28
|
-
args.last.kind_of?(Assert::Config) ? args.pop : nil
|
29
|
-
]
|
30
|
-
|
31
|
-
@output_io.sync = true if @output_io.respond_to?(:sync=)
|
32
|
-
end
|
33
|
-
|
34
|
-
def is_tty?
|
35
|
-
!!@output_io.isatty
|
36
|
-
end
|
37
|
-
|
38
|
-
def view
|
39
|
-
self
|
40
|
-
end
|
41
|
-
|
42
|
-
def config
|
43
|
-
@config ||= Assert.config
|
44
|
-
end
|
45
|
-
|
46
|
-
def suite
|
47
|
-
@suite ||= Assert.suite
|
48
|
-
end
|
49
|
-
|
50
|
-
def fire(callback, *args)
|
51
|
-
self.send(callback, *args)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Callbacks
|
55
|
-
|
56
|
-
# define callback handlers to output information. handlers are
|
57
|
-
# instance_eval'd in the scope of the view instance. any stdout is captured
|
58
|
-
# and sent to the io stream.
|
59
|
-
|
60
|
-
# available callbacks from the runner:
|
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
|
83
|
-
|
84
|
-
# IO capture
|
85
|
-
|
86
|
-
def puts(*args); @output_io.puts(*args); end
|
87
|
-
def print(*args); @output_io.print(*args); end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'ansi/code'
|
2
|
-
|
3
|
-
module Assert::View::Helpers
|
4
|
-
|
5
|
-
module AnsiStyles
|
6
|
-
|
7
|
-
def result_ansi_styles(result)
|
8
|
-
view.styled ? view.send("#{result.to_sym}_styles") : []
|
9
|
-
end
|
10
|
-
|
11
|
-
def ansi_styled_msg(msg, styles=[])
|
12
|
-
if !(style = ansi_style(*styles)).empty? && self.is_tty?
|
13
|
-
style + msg + ANSI.send(:reset)
|
14
|
-
else
|
15
|
-
msg
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def ansi_style(*ansi_codes)
|
20
|
-
ansi_codes.collect{|code| ANSI.send(code) rescue nil}.compact.join('')
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,209 +0,0 @@
|
|
1
|
-
module Assert::View::Helpers
|
2
|
-
|
3
|
-
module Common
|
4
|
-
|
5
|
-
def self.included(receiver)
|
6
|
-
receiver.class_eval{ extend ClassMethods }
|
7
|
-
end
|
8
|
-
|
9
|
-
def runner_seed
|
10
|
-
self.config.runner_seed
|
11
|
-
end
|
12
|
-
|
13
|
-
def count(type)
|
14
|
-
self.suite.count(type)
|
15
|
-
end
|
16
|
-
|
17
|
-
def tests?
|
18
|
-
self.count(:tests) > 0
|
19
|
-
end
|
20
|
-
|
21
|
-
def all_pass?
|
22
|
-
self.count(:pass) == self.count(:results)
|
23
|
-
end
|
24
|
-
|
25
|
-
# get the formatted suite run time
|
26
|
-
def run_time(format = '%.6f')
|
27
|
-
format % self.suite.run_time
|
28
|
-
end
|
29
|
-
|
30
|
-
# get the formatted suite test rate
|
31
|
-
def test_rate(format = '%.6f')
|
32
|
-
format % self.suite.test_rate
|
33
|
-
end
|
34
|
-
|
35
|
-
# get the formatted suite result rate
|
36
|
-
def result_rate(format = '%.6f')
|
37
|
-
format % self.suite.result_rate
|
38
|
-
end
|
39
|
-
|
40
|
-
# get the formatted run time for an idividual test
|
41
|
-
def test_run_time(test, format = '%.6f')
|
42
|
-
format % test.run_time
|
43
|
-
end
|
44
|
-
|
45
|
-
# get the formatted result rate for an individual test
|
46
|
-
def test_result_rate(test, format = '%.6f')
|
47
|
-
format % test.result_rate
|
48
|
-
end
|
49
|
-
|
50
|
-
# get a uniq list of contexts for the test suite
|
51
|
-
def suite_contexts
|
52
|
-
@suite_contexts ||= self.suite.tests.inject([]) do |contexts, test|
|
53
|
-
contexts << test.context_info.klass
|
54
|
-
end.uniq
|
55
|
-
end
|
56
|
-
|
57
|
-
def ordered_suite_contexts
|
58
|
-
self.suite_contexts.sort{|a,b| a.to_s <=> b.to_s}
|
59
|
-
end
|
60
|
-
|
61
|
-
# get a uniq list of files containing contexts for the test suite
|
62
|
-
def suite_files
|
63
|
-
@suite_files ||= self.suite.tests.inject([]) do |files, test|
|
64
|
-
files << test.context_info.file
|
65
|
-
end.uniq
|
66
|
-
end
|
67
|
-
|
68
|
-
def ordered_suite_files
|
69
|
-
self.suite_files.sort{|a,b| a.to_s <=> b.to_s}
|
70
|
-
end
|
71
|
-
|
72
|
-
def ordered_profile_tests
|
73
|
-
suite.ordered_tests.sort{ |a, b| a.run_time <=> b.run_time }
|
74
|
-
end
|
75
|
-
|
76
|
-
def show_test_profile_info?
|
77
|
-
!!config.profile
|
78
|
-
end
|
79
|
-
|
80
|
-
def show_test_verbose_info?
|
81
|
-
!!config.verbose
|
82
|
-
end
|
83
|
-
|
84
|
-
# get all the result details for a set of tests
|
85
|
-
def result_details_for(tests, result_order = :normal)
|
86
|
-
test_index = 0
|
87
|
-
tests.collect do |test|
|
88
|
-
test_index += 1
|
89
|
-
|
90
|
-
details = test.results.collect do |result|
|
91
|
-
ResultDetails.new(result, test, test_index)
|
92
|
-
end
|
93
|
-
details.reverse! if result_order == :reversed
|
94
|
-
details
|
95
|
-
end.compact.flatten
|
96
|
-
end
|
97
|
-
|
98
|
-
# get all the result details for a set of tests matching a file or context
|
99
|
-
def matched_result_details_for(match, tests, result_order = :normal)
|
100
|
-
context_match = match.kind_of?(Class) && match.ancestors.include?(Assert::Context)
|
101
|
-
file_match = match.kind_of?(String)
|
102
|
-
|
103
|
-
matching_tests = if context_match
|
104
|
-
tests.select {|test| test.context_info.klass == match}
|
105
|
-
elsif file_match
|
106
|
-
tests.select {|test| test.context_info.file == match}
|
107
|
-
else
|
108
|
-
tests
|
109
|
-
end
|
110
|
-
|
111
|
-
result_details_for(matching_tests, result_order)
|
112
|
-
end
|
113
|
-
|
114
|
-
# only show result details for failed or errored results
|
115
|
-
# show result details if a skip or passed result was issues w/ a message
|
116
|
-
def show_result_details?(result)
|
117
|
-
([:fail, :error].include?(result.to_sym)) ||
|
118
|
-
([:skip, :ignore].include?(result.to_sym) && result.message)
|
119
|
-
end
|
120
|
-
|
121
|
-
# show any captured output
|
122
|
-
def captured_output(output)
|
123
|
-
"--- stdout ---\n"\
|
124
|
-
"#{output}"\
|
125
|
-
"--------------"
|
126
|
-
end
|
127
|
-
|
128
|
-
# return a list of result symbols that have actually occurred
|
129
|
-
def ocurring_result_types
|
130
|
-
@result_types ||= [
|
131
|
-
:pass, :fail, :ignore, :skip, :error
|
132
|
-
].select { |result_sym| self.count(result_sym) > 0 }
|
133
|
-
end
|
134
|
-
|
135
|
-
# print a result summary message for a given result type
|
136
|
-
def result_summary_msg(result_type)
|
137
|
-
if result_type == :pass && self.all_pass?
|
138
|
-
self.all_pass_result_summary_msg
|
139
|
-
else
|
140
|
-
"#{self.count(result_type)} #{result_type.to_s}"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
# generate an appropriate result summary msg for all tests passing
|
145
|
-
def all_pass_result_summary_msg
|
146
|
-
if self.count(:results) < 1
|
147
|
-
"uhh..."
|
148
|
-
elsif self.count(:results) == 1
|
149
|
-
"pass"
|
150
|
-
else
|
151
|
-
"all pass"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
# generate a sentence fragment describing the breakdown of test results
|
156
|
-
# if a block is given, yield each msg in the breakdown for custom formatting
|
157
|
-
def results_summary_sentence
|
158
|
-
summaries = self.ocurring_result_types.collect do |result_sym|
|
159
|
-
summary_msg = self.result_summary_msg(result_sym)
|
160
|
-
block_given? ? yield(summary_msg, result_sym) : summary_msg
|
161
|
-
end
|
162
|
-
self.to_sentence(summaries)
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_count_statement
|
166
|
-
"#{self.count(:tests)} test#{'s' if self.count(:tests) != 1}"
|
167
|
-
end
|
168
|
-
|
169
|
-
def result_count_statement
|
170
|
-
"#{self.count(:results)} result#{'s' if self.count(:results) != 1}"
|
171
|
-
end
|
172
|
-
|
173
|
-
# generate a comma-seperated sentence fragment given a list of things
|
174
|
-
def to_sentence(things)
|
175
|
-
if things.size <= 2
|
176
|
-
things.join(things.size == 2 ? ' and ' : '')
|
177
|
-
else
|
178
|
-
[things[0..-2].join(", "), things.last].join(", and ")
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
class ResultDetails
|
183
|
-
attr_reader :result, :test_index, :test, :output
|
184
|
-
|
185
|
-
def initialize(result, test, test_index)
|
186
|
-
@result = result
|
187
|
-
@test = test
|
188
|
-
@test_index = test_index
|
189
|
-
@output = test.output
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
module ClassMethods
|
194
|
-
|
195
|
-
def option(name, *default_vals)
|
196
|
-
default = default_vals.size > 1 ? default_vals : default_vals.first
|
197
|
-
define_method(name) do |*args|
|
198
|
-
if !(value = args.size > 1 ? args : args.first).nil?
|
199
|
-
instance_variable_set("@#{name}", value)
|
200
|
-
end
|
201
|
-
(val = instance_variable_get("@#{name}")).nil? ? default : val
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
end
|