specdown 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +9 -0
- data/README.markdown +32 -8
- data/VERSION +1 -1
- data/features/command.feature +29 -9
- data/features/config.feature +9 -5
- data/features/specdown_examples/after_hooks/specdown/env.rb +1 -1
- data/features/specdown_examples/around_hooks/specdown/env.rb +1 -1
- data/features/specdown_examples/before_hooks/specdown/env.rb +1 -1
- data/features/specdown_examples/format_switch_test/specdown/env.rb +0 -1
- data/features/specdown_examples/nested_directories_test/specdown/env.rb +1 -1
- data/features/specdown_examples/no_ruby/specdown/env.rb +1 -1
- data/features/specdown_examples/scoped_hooks/specdown/env.rb +1 -1
- data/features/specdown_examples/with_ruby/specdown/env.rb +1 -1
- data/features/step_definitions/command.rb +107 -4
- data/lib/specdown/command/option_parser.rb +17 -5
- data/lib/specdown/config.rb +7 -1
- data/lib/specdown/event_handlers/command_complete.rb +1 -0
- data/lib/specdown/event_handlers/run_complete.rb +2 -1
- data/lib/specdown/event_handlers/run_started.rb +3 -0
- data/lib/specdown/reporter.rb +53 -0
- data/lib/specdown/reporters/color_terminal_reporter.rb +16 -0
- data/lib/specdown/{reporter → reporters}/terminal_reporter.rb +26 -13
- data/lib/specdown/reporters/text_reporter.rb +45 -0
- data/lib/specdown/runner.rb +1 -1
- data/lib/specdown/specdown.rb +1 -1
- data/lib/specdown/templates/color_summary.erb +6 -6
- data/lib/specdown.rb +4 -4
- metadata +9 -13
- data/features/reporter.feature +0 -92
- data/features/reporter_factory.feature +0 -65
- data/lib/specdown/reporter/color_terminal_reporter.rb +0 -29
- data/lib/specdown/reporter_factory.rb +0 -18
- data/lib/specdown/runner/reporter.rb +0 -27
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
New reporting and formating options at the command line.
|
6
|
+
|
7
|
+
-c, --colorized Colorize the terminal output
|
8
|
+
-n, --non-colorized Display plain terminal output
|
9
|
+
-o, --output=text|terminal output to either the terminal or a text file "specdown_report.txt". Defaults to "terminal".
|
10
|
+
-f, --format=short|condensed length and style of output. Defaults to "short".
|
11
|
+
|
3
12
|
## 0.1.7
|
4
13
|
|
5
14
|
Working on all Rubies.
|
data/README.markdown
CHANGED
@@ -239,27 +239,51 @@ You can use the `-r` flag to specify the root of the specdown directory (it defa
|
|
239
239
|
$ specdown test.markdown -r specdown_environment/
|
240
240
|
```
|
241
241
|
|
242
|
-
###
|
242
|
+
### Colorization
|
243
243
|
|
244
|
-
By default, `specdown` will output colorized terminal output. If you'd rather the output not be colorized, you can use the `-
|
244
|
+
By default, `specdown` will output colorized terminal output. If you'd rather the output not be colorized, you can use the `-n` or `--non-colorized` switch:
|
245
245
|
|
246
246
|
```sh
|
247
|
-
$ specdown -
|
247
|
+
$ specdown -n
|
248
248
|
```
|
249
249
|
|
250
|
-
|
250
|
+
You can also configure colorization in your env.rb by setting the
|
251
|
+
reporter to `Specdown::TerminalReporter`:
|
251
252
|
|
252
|
-
|
253
|
+
```ruby
|
254
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
255
|
+
```
|
256
|
+
|
257
|
+
The reporter defaults to `Specdown::ColorTerminalReporter`.
|
258
|
+
|
259
|
+
### Report format: short or condensed
|
260
|
+
|
261
|
+
Currently, we offer two report formats: short, or condensed. Short
|
262
|
+
offers only the most basic information, whereas `condensed` will provide
|
263
|
+
you with summary details per file.
|
264
|
+
|
265
|
+
You can toggle between the two either by setting switches at the command
|
266
|
+
line:
|
267
|
+
|
268
|
+
```sh
|
269
|
+
$ specdown -f short
|
270
|
+
$ specdown --format=short
|
271
|
+
$ specdown -f condensed
|
272
|
+
$ specdown --format=condensed
|
273
|
+
```
|
274
|
+
|
275
|
+
You can also configure this in your env.rb by setting
|
276
|
+
`Specdown::Config.format` to either `:short` or `:condensed`:
|
253
277
|
|
254
278
|
```ruby
|
255
|
-
Specdown::Config.
|
279
|
+
Specdown::Config.format = :condensed
|
256
280
|
```
|
257
281
|
|
258
|
-
|
282
|
+
The default it `short`.
|
259
283
|
|
260
284
|
## TODO
|
261
285
|
|
262
|
-
This library is still very new, but
|
286
|
+
This library is still very new, but I am rapidly adding features to it. Here's what is on the immediate horizon:
|
263
287
|
|
264
288
|
* offer the option of outputing the actual markdown while it executes, instead of "..F....FF......"
|
265
289
|
* Better stack traces / reporting
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/features/command.feature
CHANGED
@@ -108,13 +108,33 @@ Feature: `specdown` command
|
|
108
108
|
0 failures
|
109
109
|
"""
|
110
110
|
|
111
|
-
|
111
|
+
Scenario: colorized output switches
|
112
|
+
* The following commands should yield colorized output:
|
113
|
+
* `specdown -c`
|
114
|
+
* `specdown --colorized`
|
115
|
+
|
116
|
+
Scenario: plain output (non-colorized) switches
|
117
|
+
* The following commands should yield non-colorized output:
|
118
|
+
* `specdown -n`
|
119
|
+
* `specdown --non-colorized`
|
120
|
+
|
121
|
+
Scenario: text output
|
122
|
+
* The following commands should output reports to a text file, 'specdown_report.txt':
|
123
|
+
* `specdown -o text`
|
124
|
+
* `specdown --output=text`
|
125
|
+
|
126
|
+
Scenario: terminal output
|
127
|
+
* The following commands should output reports to STDOUT:
|
128
|
+
* `specdown -o terminal`
|
129
|
+
* `specdown --output=terminal`
|
130
|
+
|
131
|
+
Scenario: short summary output
|
132
|
+
* The following commands should output only the most basic summary information to STDOUT:
|
133
|
+
* `specdown -f short`
|
134
|
+
* `specdown --format=short`
|
135
|
+
|
112
136
|
@focus
|
113
|
-
Scenario:
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
When I run `specdown`
|
118
|
-
Then I should see colorized output
|
119
|
-
When I run `specdown -f color`
|
120
|
-
Then I should see colorized output
|
137
|
+
Scenario: short summary output
|
138
|
+
* The following commands should output summary information for each file run to STDOUT:
|
139
|
+
* `specdown -f condensed`
|
140
|
+
* `specdown --format=condensed`
|
data/features/config.feature
CHANGED
@@ -39,7 +39,7 @@ Feature: Specdown::Config
|
|
39
39
|
|
40
40
|
By default, Specdown will colorize your terminal output. If you'd prefer Specdown not to colorize your terminal output, simply set the `reporter` to `:terminal`:
|
41
41
|
|
42
|
-
Specdown.reporter ==
|
42
|
+
Specdown::Config.reporter == Specdown::TerminalReporter
|
43
43
|
|
44
44
|
\## Other reporting formats
|
45
45
|
|
@@ -48,16 +48,17 @@ Feature: Specdown::Config
|
|
48
48
|
|
49
49
|
Scenario: Specdown::Config defaults
|
50
50
|
* Specdown::Config.expectations #==> nil
|
51
|
-
* Specdown::Config.reporter #==>
|
51
|
+
* Specdown::Config.reporter #==> Specdown::ColorTerminalReporter
|
52
52
|
* Specdown::Config.root #==> "specdown"
|
53
|
-
|
53
|
+
* Specdown::Config.format #==> :short
|
54
54
|
|
55
55
|
Scenario: Reset the Specdown::Config
|
56
56
|
Given I have configured Specdown:
|
57
57
|
"""
|
58
58
|
Specdown::Config.expectations = :rspec
|
59
|
-
Specdown::Config.reporter =
|
59
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
60
60
|
Specdown::Config.root = "dir/"
|
61
|
+
Specdown::Config.format = :condensed
|
61
62
|
"""
|
62
63
|
|
63
64
|
When I reset Specdown:
|
@@ -67,8 +68,11 @@ Feature: Specdown::Config
|
|
67
68
|
|
68
69
|
Then my specdown configuration should return to its defaults:
|
69
70
|
* Specdown::Config.expectations #==> nil
|
70
|
-
* Specdown::Config.reporter #==>
|
71
|
+
* Specdown::Config.reporter #==> Specdown::ColorTerminalReporter
|
71
72
|
* Specdown::Config.root #==> "specdown"
|
73
|
+
* Specdown::Config.format #==> :short
|
74
|
+
|
75
|
+
|
72
76
|
|
73
77
|
Scenario: Default to Rspec expectations
|
74
78
|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :rspec
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :rspec
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :rspec
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1 +0,0 @@
|
|
1
|
-
Specdown::Config.reporter = :color_terminal
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :test_unit
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1 +1 @@
|
|
1
|
-
Specdown::Config.reporter =
|
1
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :rspec
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Specdown::Config.expectations = :test_unit
|
2
|
-
Specdown::Config.reporter =
|
2
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
@@ -13,7 +13,7 @@ Given /^I have a specdown directory containing a (?:single )?markdown file:$/ do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
When /^I run `specdown` with no arguments$/ do
|
16
|
-
@output =
|
16
|
+
@output = bundle_exec! "specdown"
|
17
17
|
end
|
18
18
|
|
19
19
|
Given /^a single ruby file:$/ do |string|
|
@@ -29,17 +29,120 @@ Given /^I am in a directory with a 'specdown' folder$/ do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
When /^I run `(.*)`$/ do |command|
|
32
|
-
@output =
|
32
|
+
@output = bundle_exec! command
|
33
33
|
end
|
34
34
|
|
35
35
|
Then /^I should not see colorized output$/ do
|
36
|
-
|
36
|
+
ensure_plain! @output
|
37
37
|
end
|
38
38
|
|
39
39
|
Then /^I should see colorized output$/ do
|
40
|
-
|
40
|
+
ensure_colorized! @output
|
41
|
+
end
|
42
|
+
|
43
|
+
Given /^The following commands should yield colorized output:$/ do
|
44
|
+
end
|
45
|
+
|
46
|
+
Given /^`specdown \-c`$/ do
|
47
|
+
ensure_colorized! bundle_exec!("specdown -c")
|
48
|
+
end
|
49
|
+
|
50
|
+
Given /^`specdown \-\-colorized`$/ do
|
51
|
+
ensure_colorized! bundle_exec!("specdown --colorized")
|
52
|
+
end
|
53
|
+
|
54
|
+
Given /^The following commands should yield non\-colorized output:$/ do
|
55
|
+
end
|
56
|
+
|
57
|
+
Given /^`specdown \-n`$/ do
|
58
|
+
ensure_plain! bundle_exec!("specdown -n")
|
59
|
+
end
|
60
|
+
|
61
|
+
Given /^`specdown \-\-non\-colorized`$/ do
|
62
|
+
ensure_plain! bundle_exec!("specdown --non-colorized")
|
63
|
+
end
|
64
|
+
|
65
|
+
Given /^The following commands should output reports to a text file, 'specdown_report\.txt':$/ do
|
66
|
+
end
|
67
|
+
|
68
|
+
Given /^`specdown \-o text`$/ do
|
69
|
+
ensure_text! "specdown -o text"
|
70
|
+
end
|
71
|
+
|
72
|
+
Given /^`specdown \-\-output=text`$/ do
|
73
|
+
ensure_text! "specdown --output=text"
|
74
|
+
end
|
75
|
+
|
76
|
+
Given /^The following commands should output reports to STDOUT:$/ do
|
77
|
+
end
|
78
|
+
|
79
|
+
Given /^`specdown \-o terminal`$/ do
|
80
|
+
ensure_colorized! bundle_exec!("specdown -o terminal")
|
81
|
+
end
|
82
|
+
|
83
|
+
Given /^`specdown \-\-output=terminal`$/ do
|
84
|
+
ensure_colorized! bundle_exec!("specdown --output=terminal")
|
85
|
+
end
|
86
|
+
|
87
|
+
Given /^The following commands should output only the most basic summary information to STDOUT:$/ do
|
88
|
+
end
|
89
|
+
|
90
|
+
Given /^`specdown \-f short`$/ do
|
91
|
+
ensure_short! bundle_exec!("specdown -f short")
|
92
|
+
end
|
93
|
+
|
94
|
+
Given /^`specdown \-\-format=short`$/ do
|
95
|
+
ensure_short! bundle_exec!("specdown --format=short")
|
96
|
+
end
|
97
|
+
|
98
|
+
Given /^The following commands should output summary information for each file run to STDOUT:$/ do
|
99
|
+
end
|
100
|
+
|
101
|
+
Given /^`specdown \-f condensed`$/ do
|
102
|
+
ensure_condensed! bundle_exec!("specdown -f condensed")
|
103
|
+
end
|
104
|
+
|
105
|
+
Given /^`specdown \-\-format=condensed`$/ do
|
106
|
+
ensure_condensed! bundle_exec!("specdown --format=condensed")
|
107
|
+
end
|
108
|
+
|
109
|
+
def ensure_condensed!(output)
|
110
|
+
output.strip.should_not be_empty
|
111
|
+
output.should match(/^[^\. ]+\.markdown: .*$/)
|
112
|
+
end
|
113
|
+
|
114
|
+
def ensure_short!(output)
|
115
|
+
output.strip.should_not be_empty
|
116
|
+
output.should_not match(/^[^\. ]+\.markdown: .*$/)
|
117
|
+
end
|
118
|
+
|
119
|
+
def ensure_text!(command)
|
120
|
+
output = bundle_exec! command
|
121
|
+
file_name = File.join directory, "specdown_report.txt"
|
122
|
+
proc { File.read(file_name) }.should_not raise_exception
|
123
|
+
File.delete(file_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
def ensure_colorized!(output)
|
127
|
+
raise "Oops! Output is not colorized!" unless colorized?(output)
|
128
|
+
end
|
129
|
+
|
130
|
+
def ensure_plain!(output)
|
131
|
+
raise "Oops! Output is colorized!" if colorized?(output)
|
41
132
|
end
|
42
133
|
|
43
134
|
def colorized?(output)
|
44
135
|
output.include? "\e[1m"
|
45
136
|
end
|
137
|
+
|
138
|
+
def bundle_exec(command)
|
139
|
+
"cd #{directory} && bundle exec ruby -I ../../../lib ../../../bin/#{command}"
|
140
|
+
end
|
141
|
+
|
142
|
+
def bundle_exec!(command)
|
143
|
+
`#{bundle_exec(command)}`
|
144
|
+
end
|
145
|
+
|
146
|
+
def directory
|
147
|
+
@directory ||= "features/specdown_examples/no_ruby/"
|
148
|
+
end
|
@@ -16,11 +16,12 @@ module Specdown
|
|
16
16
|
Specdown::Config.root = root
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on '-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
opts.on '-c', '--colorized', 'Colorize the terminal output' do
|
20
|
+
Specdown::Config.reporter = Specdown::ColorTerminalReporter
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on '-n', '--non-colorized', 'Display plain terminal output' do
|
24
|
+
Specdown::Config.reporter = Specdown::TerminalReporter
|
24
25
|
end
|
25
26
|
|
26
27
|
opts.on_tail '-h', '--help', 'Display this screen' do
|
@@ -28,6 +29,17 @@ module Specdown
|
|
28
29
|
exit
|
29
30
|
end
|
30
31
|
|
32
|
+
opts.on '-o', '--output=text|terminal', ["text", "terminal"], 'output to either the terminal or a text file "specdown_report.txt". Defaults to "terminal".' do |output_format|
|
33
|
+
case output_format
|
34
|
+
when "text" then Specdown::Config.reporter = Specdown::TextReporter
|
35
|
+
when "terminal" then Specdown::Config.reporter = Specdown::ColorTerminalReporter
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on '-f', '--format=short|condensed', [:short, :condensed], 'length and style of output. Defaults to "short".' do
|
40
|
+
Specdown::Config.format = format
|
41
|
+
end
|
42
|
+
|
31
43
|
opts.on_tail "-v", "--version", "Show version" do
|
32
44
|
puts File.read(File.join(File.dirname(__FILE__), "../../../VERSION"))
|
33
45
|
exit
|
data/lib/specdown/config.rb
CHANGED
@@ -6,15 +6,21 @@ module Specdown
|
|
6
6
|
attr_accessor :tests
|
7
7
|
attr_accessor :root
|
8
8
|
attr_accessor :reporter
|
9
|
+
attr_accessor :format
|
10
|
+
|
11
|
+
def format
|
12
|
+
@format ||= :short
|
13
|
+
end
|
9
14
|
|
10
15
|
def reporter
|
11
|
-
@reporter ||=
|
16
|
+
@reporter ||= Specdown::ColorTerminalReporter
|
12
17
|
end
|
13
18
|
|
14
19
|
def reset!
|
15
20
|
@expectations = nil
|
16
21
|
@reporter = nil
|
17
22
|
@root = nil
|
23
|
+
@format = nil
|
18
24
|
end
|
19
25
|
|
20
26
|
def root
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Specdown
|
2
|
+
module Reporter
|
3
|
+
def summary(runners)
|
4
|
+
ReportSummary.new(runners)
|
5
|
+
end
|
6
|
+
|
7
|
+
def print_start
|
8
|
+
raise NotImplementedError
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_runner_start(runner)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def print_runner_summary(runner)
|
16
|
+
raise NotImplementedError
|
17
|
+
end
|
18
|
+
|
19
|
+
def print_runner_end(runner)
|
20
|
+
raise NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
def print_test_start(test)
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_test_end(test)
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
def print_summary(runners)
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_success(test)
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
def print_failure(test)
|
40
|
+
raise NotImplementedError
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_end
|
44
|
+
raise NotImplementedError
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def format_stat(word, number)
|
49
|
+
plural_word = word[-2..-1] == "ss" ? "#{word}es" : "#{word}s"
|
50
|
+
"#{number} #{number == 1 ? word : plural_word}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Specdown
|
2
|
+
class ColorTerminalReporter < TerminalReporter
|
3
|
+
def success
|
4
|
+
Term::ANSIColor.green super
|
5
|
+
end
|
6
|
+
|
7
|
+
def failure
|
8
|
+
Term::ANSIColor.red(Term::ANSIColor.bold super)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def template
|
13
|
+
ERB.new File.read(File.join(File.dirname(__FILE__), "../templates/color_summary.erb"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Specdown
|
2
|
-
|
2
|
+
class TerminalReporter
|
3
|
+
include Specdown::Reporter
|
4
|
+
|
3
5
|
def success
|
4
6
|
"."
|
5
7
|
end
|
@@ -8,6 +10,29 @@ module Specdown
|
|
8
10
|
"F"
|
9
11
|
end
|
10
12
|
|
13
|
+
def print_start
|
14
|
+
end
|
15
|
+
|
16
|
+
def print_end
|
17
|
+
end
|
18
|
+
|
19
|
+
def print_runner_start(runner)
|
20
|
+
print "#{runner.file_name}: "
|
21
|
+
end
|
22
|
+
|
23
|
+
def print_runner_summary(runner)
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_runner_end(runner)
|
27
|
+
print "\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_test_start(test)
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_test_end(test)
|
34
|
+
end
|
35
|
+
|
11
36
|
def print_success(test)
|
12
37
|
print success
|
13
38
|
end
|
@@ -26,17 +51,5 @@ module Specdown
|
|
26
51
|
def template
|
27
52
|
ERB.new File.read(File.join(File.dirname(__FILE__), "../templates/summary.erb"))
|
28
53
|
end
|
29
|
-
|
30
|
-
def format_stat(word, number)
|
31
|
-
plural_word = word[-2..-1] == "ss" ? "#{word}es" : "#{word}s"
|
32
|
-
"#{number} #{number == 1 ? word : plural_word}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Specdown::ReporterFactory.decorate do |reporter|
|
38
|
-
if Specdown::Config.reporter == :terminal
|
39
|
-
reporter.extend Specdown::TerminalReporter
|
40
54
|
end
|
41
|
-
reporter
|
42
55
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Specdown
|
2
|
+
class TextReporter
|
3
|
+
include Specdown::Reporter
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@file = File.new "specdown_report.txt", "w"
|
7
|
+
end
|
8
|
+
|
9
|
+
def print_start
|
10
|
+
@file.write Time.now.to_s
|
11
|
+
@file.write "\n\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
def print_runner_start(runner)
|
15
|
+
@file.write(runner.file_name + ": ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_runner_end(runner)
|
19
|
+
@file.write "\n\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
def print_success(test)
|
23
|
+
@file.write "."
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_failure(test)
|
27
|
+
@file.write "F"
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_end
|
31
|
+
@file.close
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_summary(runners)
|
35
|
+
@report_summary = summary(runners)
|
36
|
+
bounding = binding rescue proc {}
|
37
|
+
@file.write template.result(bounding)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def template
|
42
|
+
ERB.new File.read(File.join(File.dirname(__FILE__), "../templates/summary.erb"))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/specdown/runner.rb
CHANGED
data/lib/specdown/specdown.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
---------------------------------------------------------------------------
|
4
|
-
<%= format_stat("markdown", @report_summary.num_markdowns)
|
5
|
-
<%= format_stat("test", @report_summary.num_tests)
|
6
|
-
<%= format_stat("success", @report_summary.num_successes)
|
7
|
-
<%= format_stat("failure", @report_summary.num_failures)
|
4
|
+
<%= Term::ANSIColor.bold format_stat("markdown", @report_summary.num_markdowns) %>
|
5
|
+
<%= Term::ANSIColor.bold format_stat("test", @report_summary.num_tests) %>
|
6
|
+
<%= Term::ANSIColor.green format_stat("success", @report_summary.num_successes) %>
|
7
|
+
<%= Term::ANSIColor.red format_stat("failure", @report_summary.num_failures) %>
|
8
8
|
---------------------------------------------------------------------------
|
9
9
|
|
10
10
|
<% runners.map(&:stats).each do |stat| %>
|
11
11
|
<% stat.exceptions.each do |e| %>
|
12
|
-
<%= "In #{e.test_filename}"
|
13
|
-
<%= e.exception_backtrace.join("\n")
|
12
|
+
<%= Term::ANSIColor.bold(Term::ANSIColor.blue "In #{e.test_filename}") %>: <%= Term::ANSIColor.bold(Term::ANSIColor.red "#<#{e.exception_class}>:") %> <%=e.exception_message%>
|
13
|
+
<%= Term::ANSIColor.red e.exception_backtrace.join("\n") %>
|
14
14
|
<% end %>
|
15
15
|
<% end %>
|
data/lib/specdown.rb
CHANGED
@@ -6,7 +6,7 @@ require 'specdown/parser'
|
|
6
6
|
require 'specdown/node'
|
7
7
|
require 'specdown/tree'
|
8
8
|
require 'specdown/runner'
|
9
|
-
require 'specdown/
|
9
|
+
require 'specdown/reporter'
|
10
10
|
require 'specdown/runner/stats'
|
11
11
|
require 'specdown/command'
|
12
12
|
require 'specdown/event_server'
|
@@ -23,11 +23,11 @@ require 'specdown/sandbox_factory'
|
|
23
23
|
require 'specdown/hooks'
|
24
24
|
require 'specdown/hook'
|
25
25
|
require 'specdown/command/option_parser'
|
26
|
-
require 'specdown/reporter_factory'
|
27
26
|
require 'specdown/runner/report_summary'
|
28
27
|
require 'specdown/runner/exception_facade'
|
29
|
-
require 'specdown/
|
30
|
-
require 'specdown/
|
28
|
+
require 'specdown/reporters/terminal_reporter'
|
29
|
+
require 'specdown/reporters/color_terminal_reporter'
|
30
|
+
require 'specdown/reporters/text_reporter'
|
31
31
|
require 'specdown/sandbox_decorators/default_assertion_library'
|
32
32
|
require 'specdown/sandbox_decorators/rspec_expectations'
|
33
33
|
require 'specdown/sandbox_decorators/test_unit_assertions'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Parker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: kramdown
|
@@ -103,12 +103,12 @@ files:
|
|
103
103
|
- lib/specdown/hooks.rb
|
104
104
|
- lib/specdown/node.rb
|
105
105
|
- lib/specdown/parser.rb
|
106
|
-
- lib/specdown/reporter
|
107
|
-
- lib/specdown/
|
108
|
-
- lib/specdown/
|
106
|
+
- lib/specdown/reporter.rb
|
107
|
+
- lib/specdown/reporters/color_terminal_reporter.rb
|
108
|
+
- lib/specdown/reporters/terminal_reporter.rb
|
109
|
+
- lib/specdown/reporters/text_reporter.rb
|
109
110
|
- lib/specdown/runner/exception_facade.rb
|
110
111
|
- lib/specdown/runner/report_summary.rb
|
111
|
-
- lib/specdown/runner/reporter.rb
|
112
112
|
- lib/specdown/runner/stats.rb
|
113
113
|
- lib/specdown/runner.rb
|
114
114
|
- lib/specdown/sandbox_decorators/default_assertion_library.rb
|
@@ -131,8 +131,6 @@ files:
|
|
131
131
|
- features/hooks.feature
|
132
132
|
- features/parser.feature
|
133
133
|
- features/report_summary.feature
|
134
|
-
- features/reporter.feature
|
135
|
-
- features/reporter_factory.feature
|
136
134
|
- features/runner.feature
|
137
135
|
- features/sandbox_factory.feature
|
138
136
|
- features/specdown_examples/after_hooks/specdown/env.rb
|
@@ -214,8 +212,6 @@ test_files:
|
|
214
212
|
- features/hooks.feature
|
215
213
|
- features/parser.feature
|
216
214
|
- features/report_summary.feature
|
217
|
-
- features/reporter.feature
|
218
|
-
- features/reporter_factory.feature
|
219
215
|
- features/runner.feature
|
220
216
|
- features/sandbox_factory.feature
|
221
217
|
- features/specdown_examples/after_hooks/specdown/env.rb
|
data/features/reporter.feature
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
Feature: Reporter
|
2
|
-
|
3
|
-
Specdown comes with a generic reporting class. By itself, the Specdown::Reporter does little (most methods throw a `NotImplementedError` exception). However, the `Specdown::ReporterFactory` will generate an instance of this class, then decorate based on your configuration.
|
4
|
-
|
5
|
-
For example, suppose we have the following markdown file:
|
6
|
-
|
7
|
-
\# Specdown Example
|
8
|
-
|
9
|
-
This is an example specdown file.
|
10
|
-
|
11
|
-
\## Child Node
|
12
|
-
|
13
|
-
This section is a child node. It contains some ruby code:
|
14
|
-
|
15
|
-
"simple code".should_not == nil
|
16
|
-
|
17
|
-
\### First Leaf
|
18
|
-
|
19
|
-
This section has a failure simulation:
|
20
|
-
|
21
|
-
raise "specdown error simulation!"
|
22
|
-
|
23
|
-
\## Last Leaf
|
24
|
-
|
25
|
-
This section is a leaf node. It contains some ruby code:
|
26
|
-
|
27
|
-
1.should == 1
|
28
|
-
|
29
|
-
If we create a Specdown::Runner instance from it and run it:
|
30
|
-
|
31
|
-
runner = Specdown::Runner.new("/features/fixtures/parser_example.markdown")
|
32
|
-
runner.run
|
33
|
-
|
34
|
-
We could then retrieve a report summary like so:
|
35
|
-
|
36
|
-
Specdown::Reporter.new.summary(runner).class.should == Specdown::ReportSummary
|
37
|
-
|
38
|
-
The generic reporter doesn't actually print anything:
|
39
|
-
|
40
|
-
proc { Specdown::Reporter.new.print_summary(runner) }.should raise_exception(NotImplementedError)
|
41
|
-
proc { Specdown::Reporter.new.print_success(test) }.should raise_exception(NotImplementedError)
|
42
|
-
proc { Specdown::Reporter.new.print_failure(test) }.should raise_exception(NotImplementedError)
|
43
|
-
|
44
|
-
Scenario: A Specdown::Reporter instantiated with a single stats object
|
45
|
-
|
46
|
-
Given the following specdown example file located at 'features/fixtures/parser_example.markdown':
|
47
|
-
"""
|
48
|
-
# Specdown Example
|
49
|
-
|
50
|
-
This is an example specdown file.
|
51
|
-
|
52
|
-
## Child Node
|
53
|
-
|
54
|
-
This section is a child node. It contains some ruby code:
|
55
|
-
|
56
|
-
"simple code".should_not == nil
|
57
|
-
|
58
|
-
### First Leaf
|
59
|
-
|
60
|
-
This section has a failure simulation:
|
61
|
-
|
62
|
-
raise "specdown error simulation!"
|
63
|
-
|
64
|
-
## Last Leaf
|
65
|
-
|
66
|
-
This section is a leaf node. It contains some ruby code:
|
67
|
-
|
68
|
-
1.should == 1
|
69
|
-
"""
|
70
|
-
|
71
|
-
And the following runner:
|
72
|
-
"""
|
73
|
-
@runner = Specdown::Runner.new("features/fixtures/parser_example.markdown")
|
74
|
-
"""
|
75
|
-
|
76
|
-
When I run the tests in the runner:
|
77
|
-
"""
|
78
|
-
@runner.run
|
79
|
-
"""
|
80
|
-
|
81
|
-
Then `Specdown::Reporter.new.summary(@runner)` should return a report summary object:
|
82
|
-
"""
|
83
|
-
@reporter = Specdown::Reporter.new
|
84
|
-
@reporter.summary(@runner).class.should == Specdown::ReportSummary
|
85
|
-
"""
|
86
|
-
|
87
|
-
And the generic reporter shouldn't actually print anything:
|
88
|
-
"""
|
89
|
-
proc { @reporter.print_summary(nil) }.should raise_exception(NotImplementedError)
|
90
|
-
proc { @reporter.print_success(nil) }.should raise_exception(NotImplementedError)
|
91
|
-
proc { @reporter.print_failure(nil) }.should raise_exception(NotImplementedError)
|
92
|
-
"""
|
@@ -1,65 +0,0 @@
|
|
1
|
-
Feature: Specdown::ReporterFactory
|
2
|
-
|
3
|
-
The `Specdown::ReporterFactory` will generate a `Specdown::Reporter` instance, then decorate it in various ways depending on your specdown configuration.
|
4
|
-
|
5
|
-
The `Specdown::ReporterFactory` has an API that allows you to configure new decorators for reports. Use the `Specdown::ReporterFactory.decorate` method:
|
6
|
-
|
7
|
-
Specdown::ReporterFactory.decorate do |reporter|
|
8
|
-
if Specdown::Config.reporter == :color_terminal
|
9
|
-
reporter.extend MyDecoratorModule
|
10
|
-
end
|
11
|
-
|
12
|
-
reporter
|
13
|
-
end
|
14
|
-
|
15
|
-
For example, if you configure specdown to output colorized terminal output (the default value for Specdown::Config.reporter, :color_terminal), then `Specdown::ReporterFactory` will mix the `Specdown::AnsiColor` decorator into your `Specdown::Reporter` instance.
|
16
|
-
|
17
|
-
Specdown::Config.reporter = :color_terminal
|
18
|
-
Specdown::ReporterFactory.generate.should be_kind_of(Specdown::AnsiColor)
|
19
|
-
|
20
|
-
|
21
|
-
Scenario: Adding a new decorator to Specdown::ReporterFactory
|
22
|
-
|
23
|
-
Given I have added the following decorator to `Specdown::ReporterFactory`:
|
24
|
-
"""
|
25
|
-
Specdown::ReporterFactory.decorate do |reporter|
|
26
|
-
module FactoryTester
|
27
|
-
end
|
28
|
-
|
29
|
-
reporter.extend FactoryTester
|
30
|
-
|
31
|
-
reporter
|
32
|
-
end
|
33
|
-
"""
|
34
|
-
|
35
|
-
Then reporters should be decorated with my new decorator:
|
36
|
-
"""
|
37
|
-
Specdown::ReporterFactory.generate.kind_of?(FactoryTester).should be(true)
|
38
|
-
"""
|
39
|
-
|
40
|
-
|
41
|
-
Scenario: Specdown::Config.reporter = :terminal
|
42
|
-
|
43
|
-
Given that I want a non-colorized text output report:
|
44
|
-
"""
|
45
|
-
Specdown::Config.reporter = :terminal
|
46
|
-
"""
|
47
|
-
|
48
|
-
Then `Specdown::ReporterFactory.generate` should return a `Specdown::Reporter` decorated with `Specdown::TerminalReporter`:
|
49
|
-
"""
|
50
|
-
Specdown::ReporterFactory.generate.kind_of?(Specdown::TerminalReporter).should be(true)
|
51
|
-
"""
|
52
|
-
|
53
|
-
|
54
|
-
Scenario: Specdown::Config.reporter = :color_terminal
|
55
|
-
|
56
|
-
Given that I want a colorized Specdown::Reporter:
|
57
|
-
"""
|
58
|
-
Specdown::Config.reporter = :color_terminal
|
59
|
-
"""
|
60
|
-
|
61
|
-
Then `Specdown::ReporterFactory.generate` should return a `Specdown::Reporter` decorated with `Specdown::TerminalReporter` and `Specdown::ColorTerminalReporter`:
|
62
|
-
"""
|
63
|
-
Specdown::ReporterFactory.generate.kind_of?(Specdown::TerminalReporter).should be(true)
|
64
|
-
Specdown::ReporterFactory.generate.kind_of?(Specdown::ColorTerminalReporter).should be(true)
|
65
|
-
"""
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Specdown
|
2
|
-
module ColorTerminalReporter
|
3
|
-
def success
|
4
|
-
super.green
|
5
|
-
end
|
6
|
-
|
7
|
-
def failure
|
8
|
-
super.red.bold
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
def template
|
13
|
-
ERB.new File.read(File.join(File.dirname(__FILE__), "../templates/color_summary.erb"))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Specdown::ReporterFactory.decorate do |reporter|
|
19
|
-
if Specdown::Config.reporter == :color_terminal
|
20
|
-
class ::String
|
21
|
-
include ::Term::ANSIColor
|
22
|
-
end
|
23
|
-
|
24
|
-
reporter.extend Specdown::TerminalReporter
|
25
|
-
reporter.extend Specdown::ColorTerminalReporter
|
26
|
-
end
|
27
|
-
|
28
|
-
reporter
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Specdown
|
2
|
-
module ReporterFactory
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def decorate(&block)
|
6
|
-
decorators << block
|
7
|
-
end
|
8
|
-
|
9
|
-
def generate
|
10
|
-
decorators.inject(Reporter.new) {|reporter, decorator| decorator.call(reporter) }
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def decorators
|
15
|
-
@decorators ||= []
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Specdown
|
2
|
-
class Reporter
|
3
|
-
def summary(runners)
|
4
|
-
ReportSummary.new(runners)
|
5
|
-
end
|
6
|
-
|
7
|
-
def success
|
8
|
-
raise NotImplementedError
|
9
|
-
end
|
10
|
-
|
11
|
-
def failure
|
12
|
-
raise NotImplementedError
|
13
|
-
end
|
14
|
-
|
15
|
-
def print_summary(runners)
|
16
|
-
raise NotImplementedError
|
17
|
-
end
|
18
|
-
|
19
|
-
def print_success(test)
|
20
|
-
raise NotImplementedError
|
21
|
-
end
|
22
|
-
|
23
|
-
def print_failure(test)
|
24
|
-
raise NotImplementedError
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|