spout 0.8.0.beta13 → 0.8.0.beta14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +2 -2
- data/lib/spout/commands/exporter.rb +2 -2
- data/lib/spout/commands/importer.rb +1 -0
- data/lib/spout/commands/test_runner.rb +35 -0
- data/lib/spout/templates/test/dictionary_test.rb +1 -1
- data/lib/spout/tests/domain_existence_validation.rb +4 -5
- data/lib/spout/tests/domain_format.rb +4 -5
- data/lib/spout/tests/domain_specified.rb +2 -8
- data/lib/spout/tests/form_existence_validation.rb +4 -5
- data/lib/spout/tests/json_validation.rb +3 -4
- data/lib/spout/tests/variable_type_validation.rb +3 -5
- data/lib/spout/tests.rb +62 -14
- data/lib/spout/version.rb +1 -1
- data/lib/spout.rb +3 -4
- data/spout.gemspec +2 -1
- metadata +18 -4
- data/lib/spout/hidden_reporter.rb +0 -175
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44da8a99f11bf9cf6c779e891428be644ed2caf8
|
4
|
+
data.tar.gz: 1880dbb0521218e67434e10912c0802c4b64b836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ab9390da28670115f571beec8d1a266398a0e41906668aa926e200277b115e2f267ad2a52ed07fd492b4053590bec1effb9767aabcecc779a9bb4029243e69b
|
7
|
+
data.tar.gz: 246aeeec4351aa0558e10d00320d3e1317d9801f942d9a8677742b4c9be5af16596cb9da5f669d445d6b8ed4d9bb875f5c819916652fbe3be7d584e50dd549b5
|
data/CHANGELOG.md
CHANGED
@@ -14,8 +14,10 @@
|
|
14
14
|
- The `spout coverage` command now lists domains that are defined in the data dictionary and not referenced by any variable
|
15
15
|
- Added `spout outliers` command that returns a list of integer or numeric variables that contain major and minor outliers
|
16
16
|
- Removed the deprecated `spout hybrid` command
|
17
|
+
- Spout tests are now run using minitest in favor of test unit
|
17
18
|
- **Gem Changes**
|
18
19
|
- Updated to colorize 0.7.2
|
20
|
+
- Updated to minitest
|
19
21
|
- Use of Ruby 2.1.2 is now recommended
|
20
22
|
|
21
23
|
### Bug Fix
|
data/README.md
CHANGED
@@ -104,7 +104,7 @@ If not, you can add the following to your `test` directory to include all Spout
|
|
104
104
|
```
|
105
105
|
require 'spout/tests'
|
106
106
|
|
107
|
-
class DictionaryTest < Test
|
107
|
+
class DictionaryTest < Minitest::Test
|
108
108
|
include Spout::Tests
|
109
109
|
end
|
110
110
|
```
|
@@ -112,7 +112,7 @@ end
|
|
112
112
|
```
|
113
113
|
require 'spout/tests'
|
114
114
|
|
115
|
-
class DictionaryTest < Test
|
115
|
+
class DictionaryTest < Minitest::Test
|
116
116
|
# Or only include certain tests
|
117
117
|
include Spout::Tests::JsonValidation
|
118
118
|
include Spout::Tests::VariableTypeValidation
|
@@ -23,7 +23,7 @@ module Spout
|
|
23
23
|
CSV.open("#{folder}/#{variables_export_file}", "wb") do |csv|
|
24
24
|
keys = %w(id display_name description type units domain labels calculation)
|
25
25
|
csv << ['folder'] + keys
|
26
|
-
Dir.glob("variables/**/*.json").each do |file|
|
26
|
+
Dir.glob("variables/**/*.json").sort.each do |file|
|
27
27
|
if json = JSON.parse(File.read(file)) rescue false
|
28
28
|
variable_folder = variable_folder_path(file)
|
29
29
|
csv << [variable_folder] + keys.collect{|key| json[key].kind_of?(Array) ? json[key].join(';') : json[key].to_s}
|
@@ -35,7 +35,7 @@ module Spout
|
|
35
35
|
CSV.open("#{folder}/#{domains_export_file}", "wb") do |csv|
|
36
36
|
keys = %w(value display_name description)
|
37
37
|
csv << ['folder', 'domain_id'] + keys
|
38
|
-
Dir.glob("domains/**/*.json").each do |file|
|
38
|
+
Dir.glob("domains/**/*.json").sort.each do |file|
|
39
39
|
if json = JSON.parse(File.read(file)) rescue false
|
40
40
|
domain_folder = domain_folder_path(file)
|
41
41
|
domain_name = extract_domain_name(file)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# module Spout
|
2
|
+
# module Commands
|
3
|
+
# class TestRunner
|
4
|
+
# def initialize(argv)
|
5
|
+
# verbose = (argv.delete('--verbose') != nil)
|
6
|
+
|
7
|
+
# puts "Loaded Suite test"
|
8
|
+
|
9
|
+
# files_loaded = []
|
10
|
+
|
11
|
+
|
12
|
+
# Dir.chdir("test") do
|
13
|
+
# $:.unshift(Dir.pwd)
|
14
|
+
# Dir.glob(File.join("**", "*_test.rb")).each do |test_file|
|
15
|
+
# files_loaded << test_file
|
16
|
+
# require 'spout/tests'
|
17
|
+
# Spout::Tests.class_eval File.read(test_file)
|
18
|
+
# # load test_file #.gsub(/\.rb$/, '')
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
# puts files_loaded.inspect
|
23
|
+
# puts Spout::Tests.constants
|
24
|
+
|
25
|
+
# Spout::Tests.constants.select{|c| Spout::Tests.const_get(c).is_a? Class}.each do |klass|
|
26
|
+
# puts "KLASS: #{klass}"
|
27
|
+
# my_instance = Spout::Tests.const_get(klass).new
|
28
|
+
# puts my_instance.methods.select{|m| m.to_s =~ /^test\_/}.inspect
|
29
|
+
# end
|
30
|
+
# # puts Spout::Tests::JsonValidation.methods
|
31
|
+
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
@@ -2,7 +2,7 @@ module Spout
|
|
2
2
|
module Tests
|
3
3
|
module DomainExistenceValidation
|
4
4
|
|
5
|
-
def assert_domain_existence(item
|
5
|
+
def assert_domain_existence(item)
|
6
6
|
domain_names = Dir.glob("domains/**/*.json").collect{|file| file.split('/').last.to_s.downcase.split('.json').first}
|
7
7
|
|
8
8
|
result = begin
|
@@ -13,10 +13,9 @@ module Spout
|
|
13
13
|
false
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
16
|
+
message = "The domain #{domain_name} referenced by #{item} does not exist."
|
17
|
+
|
18
|
+
assert result, message
|
20
19
|
end
|
21
20
|
|
22
21
|
Dir.glob("variables/**/*.json").each do |file|
|
@@ -2,7 +2,7 @@ module Spout
|
|
2
2
|
module Tests
|
3
3
|
module DomainFormat
|
4
4
|
|
5
|
-
def assert_domain_format(item
|
5
|
+
def assert_domain_format(item)
|
6
6
|
result = begin
|
7
7
|
json = JSON.parse(File.read(item))
|
8
8
|
if json.kind_of?(Array)
|
@@ -14,10 +14,9 @@ module Spout
|
|
14
14
|
false
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
17
|
+
message = "Must be an array of choice hashes. Ex:\n[\n {\n \"value\": \"1\",\n \"display_name\": \"Option 1\",\n \"description\": \"...\"\n },\n { ... },\n ...\n]"
|
18
|
+
|
19
|
+
assert result, message
|
21
20
|
end
|
22
21
|
|
23
22
|
Dir.glob("domains/**/*.json").each do |file|
|
@@ -4,17 +4,11 @@ module Spout
|
|
4
4
|
module Tests
|
5
5
|
module DomainSpecified
|
6
6
|
|
7
|
-
def assert_domain_specified(domain_name, msg = nil)
|
8
|
-
full_message = build_message(msg, "Variables of type choices need to specify a domain.")
|
9
|
-
assert_block(full_message) do
|
10
|
-
domain_name != nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
7
|
Dir.glob("variables/**/*.json").each do |file|
|
15
8
|
if json_value(file, :type) == "choices"
|
16
9
|
define_method("test_domain_specified:"+file) do
|
17
|
-
|
10
|
+
domain_name = json_value(file, :domain)
|
11
|
+
assert domain_name != nil, "Variables of type choices need to specify a domain."
|
18
12
|
end
|
19
13
|
end
|
20
14
|
end
|
@@ -2,7 +2,7 @@ module Spout
|
|
2
2
|
module Tests
|
3
3
|
module FormExistenceValidation
|
4
4
|
|
5
|
-
def assert_form_existence(item
|
5
|
+
def assert_form_existence(item)
|
6
6
|
form_names = Dir.glob("forms/**/*.json").collect{|file| file.split('/').last.to_s.downcase.split('.json').first}
|
7
7
|
|
8
8
|
result = begin
|
@@ -11,10 +11,9 @@ module Spout
|
|
11
11
|
false
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
message = "One or more forms referenced by #{item} does not exist."
|
15
|
+
|
16
|
+
assert result, message
|
18
17
|
end
|
19
18
|
|
20
19
|
Dir.glob("variables/**/*.json").each do |file|
|
@@ -9,10 +9,9 @@ module Spout
|
|
9
9
|
error = e
|
10
10
|
false
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
|
13
|
+
message = error.to_s
|
14
|
+
assert result, message
|
16
15
|
end
|
17
16
|
|
18
17
|
Dir.glob("variables/**/*.json").each do |file|
|
@@ -3,11 +3,9 @@ module Spout
|
|
3
3
|
module VariableTypeValidation
|
4
4
|
VALID_VARIABLE_TYPES = ['identifier', 'choices', 'integer', 'numeric', 'string', 'text', 'date', 'time', 'file', 'datetime'].sort
|
5
5
|
|
6
|
-
def assert_variable_type(item
|
7
|
-
|
8
|
-
|
9
|
-
VALID_VARIABLE_TYPES.include?(item)
|
10
|
-
end
|
6
|
+
def assert_variable_type(item)
|
7
|
+
message = "#{item} invalid variable type. Valid types: #{VALID_VARIABLE_TYPES.join(', ')}"
|
8
|
+
assert VALID_VARIABLE_TYPES.include?(item), message
|
11
9
|
end
|
12
10
|
|
13
11
|
Dir.glob("variables/**/*.json").each do |file|
|
data/lib/spout/tests.rb
CHANGED
@@ -1,8 +1,68 @@
|
|
1
|
-
require 'turn/autorun'
|
2
|
-
require 'test/unit'
|
3
1
|
require 'rubygems'
|
4
2
|
require 'json'
|
5
3
|
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'minitest/reporters'
|
6
|
+
require 'ansi/code'
|
7
|
+
|
8
|
+
module Minitest
|
9
|
+
module Reporters
|
10
|
+
class SpoutReporter < BaseReporter
|
11
|
+
include ANSI::Code
|
12
|
+
include RelativePosition
|
13
|
+
|
14
|
+
def start
|
15
|
+
super
|
16
|
+
print(white { 'Loaded Suite test' })
|
17
|
+
puts
|
18
|
+
puts
|
19
|
+
puts 'Started'
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
def report
|
24
|
+
super
|
25
|
+
puts 'Finished in %.5f seconds.' % total_time
|
26
|
+
puts
|
27
|
+
print(white { '%d tests' } % count)
|
28
|
+
print(', %d assertions, ' % assertions)
|
29
|
+
color = failures.zero? && errors.zero? ? :green : :red
|
30
|
+
print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
|
31
|
+
print(yellow { '%d skips' } % skips)
|
32
|
+
puts
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
|
36
|
+
def record(test)
|
37
|
+
super
|
38
|
+
if !test.skipped? && test.failure
|
39
|
+
print " "
|
40
|
+
print_colored_status(test)
|
41
|
+
print " #{test.name}"
|
42
|
+
puts
|
43
|
+
print " "
|
44
|
+
print test.failure
|
45
|
+
puts
|
46
|
+
puts
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def before_suite(suite)
|
53
|
+
puts suite
|
54
|
+
end
|
55
|
+
|
56
|
+
def after_suite(suite)
|
57
|
+
puts
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Minitest::Reporters.use! Minitest::Reporters::SpoutReporter.new
|
64
|
+
|
65
|
+
|
6
66
|
require 'spout/tests/json_validation'
|
7
67
|
require 'spout/tests/variable_type_validation'
|
8
68
|
require 'spout/tests/variable_name_uniqueness'
|
@@ -28,17 +88,5 @@ module Spout
|
|
28
88
|
include Spout::Tests::FormExistenceValidation
|
29
89
|
include Spout::Tests::FormNameUniqueness
|
30
90
|
include Spout::Tests::FormNameMatch
|
31
|
-
|
32
|
-
Turn.config.trace = 1
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
require 'spout/hidden_reporter'
|
37
|
-
|
38
|
-
module Turn
|
39
|
-
class Configuration
|
40
|
-
def reporter
|
41
|
-
@reporter ||= Spout::HiddenReporter.new(ENV['HIDE_PASSING_TESTS'] == 'true')
|
42
|
-
end
|
43
91
|
end
|
44
92
|
end
|
data/lib/spout/version.rb
CHANGED
data/lib/spout.rb
CHANGED
@@ -60,8 +60,6 @@ The most common spout commands are:
|
|
60
60
|
`spout new <project_name>` creates a new
|
61
61
|
data dictionary in `./<project_name>`
|
62
62
|
[t]est Run tests and show failing tests
|
63
|
-
[t] --verbose Run the tests and show passing and failing
|
64
|
-
tests
|
65
63
|
[i]mport Import a CSV file into the JSON dictionary
|
66
64
|
[e]xport [1.0.0] Export the JSON dictionary to CSV format
|
67
65
|
[c]overage Coverage report, requires dataset CSVs
|
@@ -93,8 +91,9 @@ EOT
|
|
93
91
|
end
|
94
92
|
|
95
93
|
def self.test(argv)
|
96
|
-
|
97
|
-
|
94
|
+
system "bundle exec rake"
|
95
|
+
# require 'spout/commands/test_runner'
|
96
|
+
# Spout::Commands::TestRunner.new(argv)
|
98
97
|
end
|
99
98
|
|
100
99
|
def self.version(argv)
|
data/spout.gemspec
CHANGED
@@ -27,7 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.add_dependency "rake"
|
30
|
-
spec.add_dependency "
|
30
|
+
spec.add_dependency "minitest"
|
31
|
+
spec.add_dependency "minitest-reporters"
|
31
32
|
spec.add_dependency "json"
|
32
33
|
spec.add_dependency "colorize", "~> 0.7.2"
|
33
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.
|
4
|
+
version: 0.8.0.beta14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-reporters
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -103,13 +117,13 @@ files:
|
|
103
117
|
- lib/spout/commands/importer.rb
|
104
118
|
- lib/spout/commands/outliers.rb
|
105
119
|
- lib/spout/commands/project_generator.rb
|
120
|
+
- lib/spout/commands/test_runner.rb
|
106
121
|
- lib/spout/helpers/array_statistics.rb
|
107
122
|
- lib/spout/helpers/chart_types.rb
|
108
123
|
- lib/spout/helpers/json_loader.rb
|
109
124
|
- lib/spout/helpers/number_helper.rb
|
110
125
|
- lib/spout/helpers/subject_loader.rb
|
111
126
|
- lib/spout/helpers/table_formatting.rb
|
112
|
-
- lib/spout/hidden_reporter.rb
|
113
127
|
- lib/spout/models/coverage_result.rb
|
114
128
|
- lib/spout/models/outlier_result.rb
|
115
129
|
- lib/spout/models/subject.rb
|
@@ -1,175 +0,0 @@
|
|
1
|
-
require 'turn/reporter'
|
2
|
-
|
3
|
-
module Spout
|
4
|
-
# = Based on Pretty Reporter (by Paydro)
|
5
|
-
# = Modified to hide passing tests
|
6
|
-
#
|
7
|
-
# Example output:
|
8
|
-
# TestCaseName:
|
9
|
-
# PASS test: Succesful test case. (0:00:02:059)
|
10
|
-
# ERROR test: Bogus test case. (0:00:02:059)
|
11
|
-
# FAIL test: Failed test case. (0:00:02:059)
|
12
|
-
#
|
13
|
-
class HiddenReporter < Turn::Reporter
|
14
|
-
# Second column left padding in chars.
|
15
|
-
TAB_SIZE = 10
|
16
|
-
|
17
|
-
# Character to put in front of backtrace.
|
18
|
-
TRACE_MARK = '@ '
|
19
|
-
|
20
|
-
def initialize(hide_passing_tests)
|
21
|
-
@io = $stdout
|
22
|
-
@trace = nil
|
23
|
-
@natural = nil
|
24
|
-
@verbose = nil
|
25
|
-
@mark = 0
|
26
|
-
@hide_passing_tests = hide_passing_tests
|
27
|
-
end
|
28
|
-
|
29
|
-
# At the very start, before any testcases are run, this is called.
|
30
|
-
def start_suite(suite)
|
31
|
-
@suite = suite
|
32
|
-
@time = Time.now
|
33
|
-
|
34
|
-
io.puts Turn::Colorize.bold("Loaded Suite #{suite.name}")
|
35
|
-
io.puts
|
36
|
-
if suite.seed
|
37
|
-
io.puts "Started at #{Time.now} w/ seed #{suite.seed}."
|
38
|
-
else
|
39
|
-
io.puts "Started at #{Time.now}."
|
40
|
-
end
|
41
|
-
io.puts
|
42
|
-
end
|
43
|
-
|
44
|
-
# Invoked before a testcase is run.
|
45
|
-
def start_case(kase)
|
46
|
-
# Print case name if there any tests in suite
|
47
|
-
# TODO: Add option which will show all test cases, even without tests?
|
48
|
-
io.puts kase.name if kase.size > 0
|
49
|
-
end
|
50
|
-
|
51
|
-
# Invoked before a test is run.
|
52
|
-
def start_test(test)
|
53
|
-
@test_time = Time.now
|
54
|
-
@test = test
|
55
|
-
end
|
56
|
-
|
57
|
-
# Invoked when a test passes.
|
58
|
-
def pass(message=nil)
|
59
|
-
unless @hide_passing_tests
|
60
|
-
banner PASS
|
61
|
-
|
62
|
-
if message
|
63
|
-
message = Turn::Colorize.magenta(message)
|
64
|
-
message = message.to_s.tabto(TAB_SIZE)
|
65
|
-
|
66
|
-
io.puts(message)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# Invoked when a test raises an assertion.
|
72
|
-
def fail(assertion, message=nil)
|
73
|
-
banner FAIL
|
74
|
-
|
75
|
-
prettify(assertion, message)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Invoked when a test raises an exception.
|
79
|
-
def error(exception, message=nil)
|
80
|
-
banner ERROR
|
81
|
-
|
82
|
-
prettify(exception, message)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Invoked when a test is skipped.
|
86
|
-
def skip(exception, message=nil)
|
87
|
-
banner SKIP
|
88
|
-
|
89
|
-
prettify(exception, message)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Invoked after all tests in a testcase have ben run.
|
93
|
-
def finish_case(kase)
|
94
|
-
# Print newline is there any tests in suite
|
95
|
-
io.puts if kase.size > 0
|
96
|
-
end
|
97
|
-
|
98
|
-
# After all tests are run, this is the last observable action.
|
99
|
-
def finish_suite(suite)
|
100
|
-
total = colorize_count("%d tests", suite.count_tests, :bold)
|
101
|
-
passes = colorize_count("%d passed", suite.count_passes, :pass)
|
102
|
-
assertions = colorize_count("%d assertions", suite.count_assertions, nil)
|
103
|
-
failures = colorize_count("%d failures", suite.count_failures, :fail)
|
104
|
-
errors = colorize_count("%d errors", suite.count_errors, :error)
|
105
|
-
skips = colorize_count("%d skips", suite.count_skips, :skip)
|
106
|
-
|
107
|
-
io.puts "Finished in %.6f seconds." % (Time.now - @time)
|
108
|
-
io.puts
|
109
|
-
|
110
|
-
io.puts [ total, passes, failures, errors, skips, assertions ].join(", ")
|
111
|
-
|
112
|
-
# Please keep this newline, since it will be useful when after test case
|
113
|
-
# there will be other lines. For example "rake aborted!" or kind of.
|
114
|
-
io.puts
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
# Creates an optionally-colorized string describing the number of occurances an event occurred.
|
119
|
-
#
|
120
|
-
# @param [String] str A printf-style string that expects an integer argument (i.e. the count)
|
121
|
-
# @param [Integer] count The number of occurances of the event being described.
|
122
|
-
# @param [nil, Symbol] colorize_method The method on Turn::Colorize to call in order to apply color to the result, or nil
|
123
|
-
# to not apply any coloring at all.
|
124
|
-
def colorize_count(str, count, colorize_method)
|
125
|
-
str= str % [count]
|
126
|
-
str= Turn::Colorize.send(colorize_method, str) if colorize_method and count != 0
|
127
|
-
str
|
128
|
-
end
|
129
|
-
|
130
|
-
# TODO: Could also provide % done with time info. But it's already taking up
|
131
|
-
# a lot of screen realestate. Maybe use --verbose flag to offer two forms.
|
132
|
-
|
133
|
-
# Outputs test case header for given event (error, fail & etc)
|
134
|
-
#
|
135
|
-
# Example:
|
136
|
-
# PASS test: Test decription. (0.15s 0:00:02:059)
|
137
|
-
def banner(event)
|
138
|
-
name = naturalized_name(@test)
|
139
|
-
delta = Time.now - @test_time # test runtime
|
140
|
-
if @verbose
|
141
|
-
out = "%18s (%0.5fs) (%s) %s" % [event, delta, ticktock, name]
|
142
|
-
else
|
143
|
-
out = "%18s (%s) %s" % [event, ticktock, name]
|
144
|
-
end
|
145
|
-
if @mark > 0 && delta > @mark
|
146
|
-
out[1] = Turn::Colorize.mark('*')
|
147
|
-
end
|
148
|
-
io.puts out
|
149
|
-
end
|
150
|
-
|
151
|
-
# Cleanups and prints test payload
|
152
|
-
#
|
153
|
-
# Example:
|
154
|
-
# fail is not 1
|
155
|
-
# @ test/test_runners.rb:46:in `test_autorun_with_trace'
|
156
|
-
# bin/turn:4:in `<main>'
|
157
|
-
def prettify(raised, message=nil)
|
158
|
-
# Get message from raised, if not given
|
159
|
-
message ||= raised.message
|
160
|
-
|
161
|
-
backtrace = raised.respond_to?(:backtrace) ? raised.backtrace : raised.location
|
162
|
-
|
163
|
-
# Filter and clean backtrace
|
164
|
-
backtrace = clean_backtrace(backtrace)
|
165
|
-
|
166
|
-
# Add trace mark to first line.
|
167
|
-
backtrace.first.insert(0, TRACE_MARK)
|
168
|
-
|
169
|
-
io.puts Turn::Colorize.bold(message.tabto(TAB_SIZE))
|
170
|
-
io.puts backtrace.shift.tabto(TAB_SIZE - TRACE_MARK.length)
|
171
|
-
io.puts backtrace.join("\n").tabto(TAB_SIZE)
|
172
|
-
io.puts
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|