specdown 0.3.0 → 0.4.0.beta.1
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.
- data/CHANGELOG.markdown +7 -0
- data/README.markdown +84 -8
- data/VERSION +1 -1
- data/features/command.feature +3 -1
- data/features/config.feature +3 -3
- data/features/fixtures/codeblocks_and_implicits.markdown +7 -0
- data/features/implicit_parser.feature +113 -0
- data/features/implicit_specs.feature +135 -0
- data/features/parser.feature +69 -1
- data/features/pending_specs.feature +49 -0
- data/features/report_summary.feature +1 -1
- data/features/specdown_examples/complete_implicit/specdown/implicit.specdown +4 -0
- data/features/specdown_examples/complete_implicit/specdown/test.markdown +3 -0
- data/features/specdown_examples/no_implicit/specdown/test.markdown +3 -0
- data/features/specdown_examples/pending_implicit/specdown/implicit.specdown +4 -0
- data/features/specdown_examples/pending_implicit/specdown/test.markdown +3 -0
- data/features/specdown_examples/pending_specs/specdown/test.markdown +7 -0
- data/features/step_definitions/command.rb +7 -3
- data/features/step_definitions/implicit_parser.rb +19 -0
- data/features/step_definitions/implicit_specs.rb +18 -0
- data/features/step_definitions/parser.rb +24 -0
- data/features/step_definitions/pending_specs.rb +7 -0
- data/features/support/env.rb +6 -0
- data/lib/specdown.rb +6 -0
- data/lib/specdown/config.rb +12 -1
- data/lib/specdown/event_handlers/test_pending.rb +3 -0
- data/lib/specdown/event_handlers/test_undefined.rb +3 -0
- data/lib/specdown/implicit_parser.rb +47 -0
- data/lib/specdown/node.rb +2 -1
- data/lib/specdown/parser.rb +40 -6
- data/lib/specdown/pending.rb +7 -0
- data/lib/specdown/pending_exception.rb +4 -0
- data/lib/specdown/reporter.rb +8 -0
- data/lib/specdown/reporters/color_terminal_reporter.rb +12 -0
- data/lib/specdown/reporters/terminal_reporter.rb +16 -0
- data/lib/specdown/reporters/text_reporter.rb +8 -0
- data/lib/specdown/runner.rb +25 -16
- data/lib/specdown/runner/report_summary.rb +8 -0
- data/lib/specdown/runner/stats.rb +13 -2
- data/lib/specdown/sandbox_decorators/pending.rb +3 -0
- data/lib/specdown/templates/color_summary.erb +20 -4
- data/lib/specdown/templates/summary.erb +17 -0
- metadata +45 -9
data/lib/specdown/reporter.rb
CHANGED
@@ -8,6 +8,18 @@ module Specdown
|
|
8
8
|
Term::ANSIColor.red(Term::ANSIColor.bold super)
|
9
9
|
end
|
10
10
|
|
11
|
+
def success
|
12
|
+
Term::ANSIColor.blue super
|
13
|
+
end
|
14
|
+
|
15
|
+
def undefined
|
16
|
+
Term::ANSIColor.yellow super
|
17
|
+
end
|
18
|
+
|
19
|
+
def print_runner_start(runner)
|
20
|
+
print Term::ANSIColor.bold("#{runner.file_name}: ")
|
21
|
+
end
|
22
|
+
|
11
23
|
private
|
12
24
|
def template
|
13
25
|
ERB.new File.read(File.join(File.dirname(__FILE__), "../templates/color_summary.erb"))
|
@@ -10,6 +10,14 @@ module Specdown
|
|
10
10
|
"F"
|
11
11
|
end
|
12
12
|
|
13
|
+
def pending
|
14
|
+
"P"
|
15
|
+
end
|
16
|
+
|
17
|
+
def undefined
|
18
|
+
"U"
|
19
|
+
end
|
20
|
+
|
13
21
|
def print_start
|
14
22
|
end
|
15
23
|
|
@@ -37,10 +45,18 @@ module Specdown
|
|
37
45
|
print success
|
38
46
|
end
|
39
47
|
|
48
|
+
def print_pending(test)
|
49
|
+
print pending
|
50
|
+
end
|
51
|
+
|
40
52
|
def print_failure(test)
|
41
53
|
print failure
|
42
54
|
end
|
43
55
|
|
56
|
+
def print_undefined(test)
|
57
|
+
print undefined
|
58
|
+
end
|
59
|
+
|
44
60
|
def print_summary(runners)
|
45
61
|
@report_summary = summary(runners)
|
46
62
|
bounding = binding rescue proc {}
|
data/lib/specdown/runner.rb
CHANGED
@@ -4,7 +4,7 @@ module Specdown
|
|
4
4
|
|
5
5
|
def initialize(file_path)
|
6
6
|
@file_path = file_path
|
7
|
-
@tree = Parser.parse File.read(file_path)
|
7
|
+
@tree = Parser.parse File.read(file_path), Specdown::Config.implicit_specs
|
8
8
|
@stats = Stats.new self
|
9
9
|
end
|
10
10
|
|
@@ -20,32 +20,41 @@ module Specdown
|
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
|
-
def depth_first_search(node, code=[])
|
23
|
+
def depth_first_search(node, code=[], undefined_implicits=[])
|
24
24
|
if node.children.empty?
|
25
25
|
EventServer.event :before_test, self
|
26
|
-
execute_test(code + [node.code])
|
26
|
+
execute_test(code + [node.code], undefined_implicits + node.undefined_implicits)
|
27
27
|
EventServer.event :after_test, self
|
28
28
|
else
|
29
29
|
node.children.each do |child|
|
30
|
-
depth_first_search(child, (code + [node.code]))
|
30
|
+
depth_first_search(child, (code + [node.code]), (undefined_implicits + node.undefined_implicits))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def execute_test(code)
|
35
|
+
def execute_test(code, undefined_implicits)
|
36
36
|
@stats.tests += 1
|
37
|
-
|
38
|
-
begin
|
39
|
-
Specdown.sandbox.instance_eval <<-CODE, file_name
|
40
|
-
#{code.join("\n")}
|
41
|
-
CODE
|
42
|
-
|
43
|
-
EventServer.event :test_passed, self
|
44
|
-
|
45
|
-
rescue Exception => e
|
46
|
-
@stats.exceptions << ExceptionFacade.new(e, self)
|
47
37
|
|
48
|
-
|
38
|
+
if !undefined_implicits.empty?
|
39
|
+
@stats.undefined_tests += 1
|
40
|
+
@stats.undefined_implicits += undefined_implicits
|
41
|
+
EventServer.event :test_undefined, self
|
42
|
+
else
|
43
|
+
|
44
|
+
begin
|
45
|
+
Specdown.sandbox.instance_eval <<-CODE, file_name
|
46
|
+
#{code.join("\n")}
|
47
|
+
CODE
|
48
|
+
EventServer.event :test_passed, self
|
49
|
+
|
50
|
+
rescue Specdown::PendingException => e
|
51
|
+
@stats.pending_exceptions << ExceptionFacade.new(e, self)
|
52
|
+
EventServer.event :test_pending, self
|
53
|
+
|
54
|
+
rescue Exception => e
|
55
|
+
@stats.exceptions << ExceptionFacade.new(e, self)
|
56
|
+
EventServer.event :test_failed, self
|
57
|
+
end
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
@@ -14,6 +14,14 @@ module Specdown
|
|
14
14
|
@num_tests ||= @runners.map(&:stats).map(&:tests).inject(0, &:+)
|
15
15
|
end
|
16
16
|
|
17
|
+
def num_pendings
|
18
|
+
@num_pendings ||= @runners.map(&:stats).map(&:pendings).inject(0, &:+)
|
19
|
+
end
|
20
|
+
|
21
|
+
def num_undefined
|
22
|
+
@num_undefined ||= @runners.map(&:stats).map(&:undefined).inject(0, &:+)
|
23
|
+
end
|
24
|
+
|
17
25
|
def num_failures
|
18
26
|
@num_failures ||= @runners.map(&:stats).map(&:failures).inject(0, &:+)
|
19
27
|
end
|
@@ -1,20 +1,31 @@
|
|
1
1
|
module Specdown
|
2
2
|
class Stats
|
3
|
-
attr_accessor :tests, :exceptions
|
3
|
+
attr_accessor :tests, :exceptions, :pending_exceptions, :undefined_implicits, :undefined_tests
|
4
4
|
attr_reader :runner
|
5
5
|
|
6
6
|
def initialize(source_runner=nil)
|
7
7
|
@runner = source_runner
|
8
8
|
@tests = 0
|
9
9
|
@exceptions = []
|
10
|
+
@pending_exceptions = []
|
11
|
+
@undefined_implicits = []
|
12
|
+
@undefined_tests = 0
|
10
13
|
end
|
11
14
|
|
12
15
|
def successes
|
13
|
-
@tests -
|
16
|
+
@tests - failures - pendings - undefined_tests
|
14
17
|
end
|
15
18
|
|
16
19
|
def failures
|
17
20
|
@exceptions.count
|
18
21
|
end
|
22
|
+
|
23
|
+
def pendings
|
24
|
+
@pending_exceptions.count
|
25
|
+
end
|
26
|
+
|
27
|
+
def undefined
|
28
|
+
@undefined_implicits.count
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
@@ -3,13 +3,29 @@
|
|
3
3
|
---------------------------------------------------------------------------
|
4
4
|
<%= Term::ANSIColor.bold format_stat("markdown", @report_summary.num_markdowns) %>
|
5
5
|
<%= Term::ANSIColor.bold format_stat("test", @report_summary.num_tests) %>
|
6
|
-
<%= Term::ANSIColor.
|
7
|
-
<%= Term::ANSIColor.
|
6
|
+
<%= Term::ANSIColor.cyan format_stat("pending test", @report_summary.num_pendings) %>
|
7
|
+
<%= Term::ANSIColor.green format_stat("success", @report_summary.num_successes) %>
|
8
|
+
<%= Term::ANSIColor.red format_stat("failure", @report_summary.num_failures) %>
|
9
|
+
<%= Term::ANSIColor.yellow(@report_summary.num_undefined.to_s + " undefined") %>
|
8
10
|
---------------------------------------------------------------------------
|
9
|
-
|
10
11
|
<% runners.map(&:stats).each do |stat| %>
|
11
12
|
<% stat.exceptions.each do |e| %>
|
12
|
-
<%= Term::ANSIColor.bold(Term::ANSIColor.
|
13
|
+
<%= Term::ANSIColor.bold(Term::ANSIColor.cyan "In #{e.test_filename}") %>: <%= Term::ANSIColor.bold(Term::ANSIColor.red "#<#{e.exception_class}>:") %> <%=e.exception_message%>
|
13
14
|
<%= Term::ANSIColor.red e.exception_backtrace.join("\n") %>
|
14
15
|
<% end %>
|
15
16
|
<% end %>
|
17
|
+
<% runners.collect(&:stats).collect(&:pending_exceptions).flatten.each do |pending_exception| %>
|
18
|
+
<%= Term::ANSIColor.bold(Term::ANSIColor.cyan "In #{pending_exception.test_filename}") %>: <%= Term::ANSIColor.bold(Term::ANSIColor.red "#<#{pending_exception.exception_class}>:") %> <%=pending_exception.exception_message%>
|
19
|
+
<%= Term::ANSIColor.red pending_exception.exception_backtrace.join("\n") %>
|
20
|
+
<% end %>
|
21
|
+
<% if @report_summary.num_undefined > 0 %>
|
22
|
+
<%= Term::ANSIColor.yellow 'Now add the following implicit spec definition to a file suffixed with ".specdown":'%>
|
23
|
+
<% end %>
|
24
|
+
<% runners.collect(&:stats).collect(&:undefined_implicits).flatten.each do |implicit_key| %>
|
25
|
+
<%= Term::ANSIColor.yellow implicit_key %>
|
26
|
+
<%= Term::ANSIColor.yellow("-" * implicit_key.length) %>
|
27
|
+
|
28
|
+
<%= Term::ANSIColor.yellow " pending # replace this with the code you wish you had" %>
|
29
|
+
|
30
|
+
|
31
|
+
<% end %>
|
@@ -3,12 +3,29 @@
|
|
3
3
|
---------------------------------------------------------------------------
|
4
4
|
<%= format_stat("markdown", @report_summary.num_markdowns) %>
|
5
5
|
<%= format_stat("test", @report_summary.num_tests) %>
|
6
|
+
<%= format_stat("pending test", @report_summary.num_pendings)%>
|
6
7
|
<%= format_stat("success", @report_summary.num_successes) %>
|
7
8
|
<%= format_stat("failure", @report_summary.num_failures) %>
|
9
|
+
<%= @report_summary.num_undefined %> undefined
|
8
10
|
---------------------------------------------------------------------------
|
9
11
|
<% runners.map(&:stats).each do |stat| %>
|
10
12
|
<% stat.exceptions.each do |e| %>
|
11
13
|
In <%=e.test_filename%>: <#<%=e.exception_class%>> <%=e.exception_message%>
|
12
14
|
<%= e.exception_backtrace.join "\n" %>
|
13
15
|
<% end %>
|
16
|
+
<% stat.pending_exceptions.each do |e| %>
|
17
|
+
In <%=e.test_filename%>: <#<%=e.exception_class%>> <%=e.exception_message%>
|
18
|
+
<%= e.exception_backtrace.join "\n" %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% if @report_summary.num_undefined > 0 %>
|
22
|
+
Now add the following implicit spec definition to a file suffixed with ".specdown":
|
23
|
+
<% end %>
|
24
|
+
<% runners.collect(&:stats).collect(&:undefined_implicits).flatten.each do |implicit_key| %>
|
25
|
+
<%= implicit_key %>
|
26
|
+
<%= "-" * implicit_key.length %>
|
27
|
+
|
28
|
+
pending # replace this with the code you wish you had
|
29
|
+
|
30
|
+
|
14
31
|
<% end %>
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -1605695984
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 0.4.0.beta.1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Matt Parker
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-01-
|
20
|
+
date: 2012-01-22 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
name: gitdown
|
@@ -98,11 +100,16 @@ files:
|
|
98
100
|
- lib/specdown/event_handlers/run_started.rb
|
99
101
|
- lib/specdown/event_handlers/test_failed.rb
|
100
102
|
- lib/specdown/event_handlers/test_passed.rb
|
103
|
+
- lib/specdown/event_handlers/test_pending.rb
|
104
|
+
- lib/specdown/event_handlers/test_undefined.rb
|
101
105
|
- lib/specdown/event_server.rb
|
102
106
|
- lib/specdown/hook.rb
|
103
107
|
- lib/specdown/hooks.rb
|
108
|
+
- lib/specdown/implicit_parser.rb
|
104
109
|
- lib/specdown/node.rb
|
105
110
|
- lib/specdown/parser.rb
|
111
|
+
- lib/specdown/pending.rb
|
112
|
+
- lib/specdown/pending_exception.rb
|
106
113
|
- lib/specdown/reporter.rb
|
107
114
|
- lib/specdown/reporters/color_terminal_reporter.rb
|
108
115
|
- lib/specdown/reporters/terminal_reporter.rb
|
@@ -112,6 +119,7 @@ files:
|
|
112
119
|
- lib/specdown/runner/stats.rb
|
113
120
|
- lib/specdown/runner.rb
|
114
121
|
- lib/specdown/sandbox_decorators/default_assertion_library.rb
|
122
|
+
- lib/specdown/sandbox_decorators/pending.rb
|
115
123
|
- lib/specdown/sandbox_decorators/rspec_expectations.rb
|
116
124
|
- lib/specdown/sandbox_decorators/test_unit_assertions.rb
|
117
125
|
- lib/specdown/sandbox_factory.rb
|
@@ -127,11 +135,15 @@ files:
|
|
127
135
|
- features/config.feature
|
128
136
|
- features/event_server.feature
|
129
137
|
- features/exception_facade.feature
|
138
|
+
- features/fixtures/codeblocks_and_implicits.markdown
|
130
139
|
- features/fixtures/multiple_codeblocks_per_section_example.markdown
|
131
140
|
- features/fixtures/non_executing_example.markdown
|
132
141
|
- features/fixtures/parser_example.markdown
|
133
142
|
- features/hooks.feature
|
143
|
+
- features/implicit_parser.feature
|
144
|
+
- features/implicit_specs.feature
|
134
145
|
- features/parser.feature
|
146
|
+
- features/pending_specs.feature
|
135
147
|
- features/report_summary.feature
|
136
148
|
- features/runner.feature
|
137
149
|
- features/sandbox_factory.feature
|
@@ -144,13 +156,19 @@ files:
|
|
144
156
|
- features/specdown_examples/before_hooks/specdown/env.rb
|
145
157
|
- features/specdown_examples/before_hooks/specdown/hooks.rb
|
146
158
|
- features/specdown_examples/before_hooks/specdown/parser_example.markdown
|
159
|
+
- features/specdown_examples/complete_implicit/specdown/implicit.specdown
|
160
|
+
- features/specdown_examples/complete_implicit/specdown/test.markdown
|
147
161
|
- features/specdown_examples/format_switch_test/specdown/env.rb
|
148
162
|
- features/specdown_examples/nested_directories_test/specdown/env.rb
|
149
163
|
- features/specdown_examples/nested_directories_test/specdown/tests/1.markdown
|
150
164
|
- features/specdown_examples/nested_directories_test/specdown/tests/2.markdown
|
151
165
|
- features/specdown_examples/nested_directories_test/specdown/tests/3.markdown
|
166
|
+
- features/specdown_examples/no_implicit/specdown/test.markdown
|
152
167
|
- features/specdown_examples/no_ruby/specdown/env.rb
|
153
168
|
- features/specdown_examples/no_ruby/specdown/parser_example.markdown
|
169
|
+
- features/specdown_examples/pending_implicit/specdown/implicit.specdown
|
170
|
+
- features/specdown_examples/pending_implicit/specdown/test.markdown
|
171
|
+
- features/specdown_examples/pending_specs/specdown/test.markdown
|
154
172
|
- features/specdown_examples/scoped_hooks/specdown/env.rb
|
155
173
|
- features/specdown_examples/scoped_hooks/specdown/hooks.rb
|
156
174
|
- features/specdown_examples/scoped_hooks/specdown/parser_example.markdown
|
@@ -164,7 +182,10 @@ files:
|
|
164
182
|
- features/step_definitions/event_server.rb
|
165
183
|
- features/step_definitions/exception_facade.rb
|
166
184
|
- features/step_definitions/hooks.rb
|
185
|
+
- features/step_definitions/implicit_parser.rb
|
186
|
+
- features/step_definitions/implicit_specs.rb
|
167
187
|
- features/step_definitions/parser.rb
|
188
|
+
- features/step_definitions/pending_specs.rb
|
168
189
|
- features/step_definitions/report_summary.rb
|
169
190
|
- features/step_definitions/reporter.rb
|
170
191
|
- features/step_definitions/reporter_factory.rb
|
@@ -192,12 +213,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
214
|
none: false
|
194
215
|
requirements:
|
195
|
-
- - "
|
216
|
+
- - ">"
|
196
217
|
- !ruby/object:Gem::Version
|
197
|
-
hash:
|
218
|
+
hash: 25
|
198
219
|
segments:
|
199
|
-
-
|
200
|
-
|
220
|
+
- 1
|
221
|
+
- 3
|
222
|
+
- 1
|
223
|
+
version: 1.3.1
|
201
224
|
requirements: []
|
202
225
|
|
203
226
|
rubyforge_project:
|
@@ -210,11 +233,15 @@ test_files:
|
|
210
233
|
- features/config.feature
|
211
234
|
- features/event_server.feature
|
212
235
|
- features/exception_facade.feature
|
236
|
+
- features/fixtures/codeblocks_and_implicits.markdown
|
213
237
|
- features/fixtures/multiple_codeblocks_per_section_example.markdown
|
214
238
|
- features/fixtures/non_executing_example.markdown
|
215
239
|
- features/fixtures/parser_example.markdown
|
216
240
|
- features/hooks.feature
|
241
|
+
- features/implicit_parser.feature
|
242
|
+
- features/implicit_specs.feature
|
217
243
|
- features/parser.feature
|
244
|
+
- features/pending_specs.feature
|
218
245
|
- features/report_summary.feature
|
219
246
|
- features/runner.feature
|
220
247
|
- features/sandbox_factory.feature
|
@@ -227,13 +254,19 @@ test_files:
|
|
227
254
|
- features/specdown_examples/before_hooks/specdown/env.rb
|
228
255
|
- features/specdown_examples/before_hooks/specdown/hooks.rb
|
229
256
|
- features/specdown_examples/before_hooks/specdown/parser_example.markdown
|
257
|
+
- features/specdown_examples/complete_implicit/specdown/implicit.specdown
|
258
|
+
- features/specdown_examples/complete_implicit/specdown/test.markdown
|
230
259
|
- features/specdown_examples/format_switch_test/specdown/env.rb
|
231
260
|
- features/specdown_examples/nested_directories_test/specdown/env.rb
|
232
261
|
- features/specdown_examples/nested_directories_test/specdown/tests/1.markdown
|
233
262
|
- features/specdown_examples/nested_directories_test/specdown/tests/2.markdown
|
234
263
|
- features/specdown_examples/nested_directories_test/specdown/tests/3.markdown
|
264
|
+
- features/specdown_examples/no_implicit/specdown/test.markdown
|
235
265
|
- features/specdown_examples/no_ruby/specdown/env.rb
|
236
266
|
- features/specdown_examples/no_ruby/specdown/parser_example.markdown
|
267
|
+
- features/specdown_examples/pending_implicit/specdown/implicit.specdown
|
268
|
+
- features/specdown_examples/pending_implicit/specdown/test.markdown
|
269
|
+
- features/specdown_examples/pending_specs/specdown/test.markdown
|
237
270
|
- features/specdown_examples/scoped_hooks/specdown/env.rb
|
238
271
|
- features/specdown_examples/scoped_hooks/specdown/hooks.rb
|
239
272
|
- features/specdown_examples/scoped_hooks/specdown/parser_example.markdown
|
@@ -247,7 +280,10 @@ test_files:
|
|
247
280
|
- features/step_definitions/event_server.rb
|
248
281
|
- features/step_definitions/exception_facade.rb
|
249
282
|
- features/step_definitions/hooks.rb
|
283
|
+
- features/step_definitions/implicit_parser.rb
|
284
|
+
- features/step_definitions/implicit_specs.rb
|
250
285
|
- features/step_definitions/parser.rb
|
286
|
+
- features/step_definitions/pending_specs.rb
|
251
287
|
- features/step_definitions/report_summary.rb
|
252
288
|
- features/step_definitions/reporter.rb
|
253
289
|
- features/step_definitions/reporter_factory.rb
|