specdown 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +9 -1
- data/README.markdown +22 -0
- data/VERSION +1 -0
- data/features/command.feature +11 -1
- data/features/reporter_factory.feature +5 -3
- data/features/sandbox_factory.feature +55 -0
- data/features/specdown_examples/format_switch_test/specdown/env.rb +1 -0
- data/features/step_definitions/command.rb +16 -0
- data/features/step_definitions/sandbox_factory.rb +11 -0
- data/lib/specdown/command/option_parser.rb +13 -1
- data/lib/specdown/command.rb +1 -1
- data/lib/specdown/reporter/terminal_reporter.rb +2 -1
- data/lib/specdown/sandbox_decorators/default_assertion_library.rb +11 -0
- data/lib/specdown/sandbox_decorators/rspec_expectations.rb +6 -0
- data/lib/specdown/sandbox_decorators/test_unit_assertions.rb +6 -0
- data/lib/specdown/sandbox_factory.rb +8 -42
- data/lib/specdown.rb +3 -0
- metadata +14 -4
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
|
3
|
+
## 0.1.6
|
4
|
+
|
5
|
+
Command line option (-f or --format) for output format (plain|color).
|
6
|
+
|
7
|
+
Command line option (-v or --version) for specdown version.
|
8
|
+
|
9
|
+
Also, created an API for sandbox decoration. Send me your pull requests :-)
|
10
|
+
|
3
11
|
## 0.1.5
|
4
12
|
|
5
13
|
Terminal output is now colorized, by default. To turn it off, add the following to your env.rb:
|
@@ -16,7 +24,7 @@ The `specdown` command now allows you to pass off directories of tests as well a
|
|
16
24
|
|
17
25
|
The `specdown` command now accepts two options: -h and -r.
|
18
26
|
|
19
|
-
Usage: specdown [
|
27
|
+
Usage: specdown [file|dir [file|dir [file|dir....]]]
|
20
28
|
-r, --root SPECDOWN_DIR defaults to ./specdown
|
21
29
|
-h, --help Display this screen
|
22
30
|
|
data/README.markdown
CHANGED
@@ -220,6 +220,8 @@ You can run `specdown -h` at the command line to get USAGE and options.
|
|
220
220
|
|
221
221
|
If you run `specdown` without any arguments, specdown will look for a "specdown" directory inside your current working directory, then search for any markdown files inside of it, and also load any ruby files inside of it.
|
222
222
|
|
223
|
+
### Running specific files (or directories)
|
224
|
+
|
223
225
|
If you want to run just a single file or a set of files, or a directory of files, simply pass them on the command line:
|
224
226
|
|
225
227
|
```sh
|
@@ -227,12 +229,32 @@ $ specdown specdown/test.markdown
|
|
227
229
|
$ specdown specdown/unit_tests
|
228
230
|
```
|
229
231
|
|
232
|
+
### Overriding the default root directory
|
233
|
+
|
230
234
|
You can use the `-r` flag to specify the root of the specdown directory (it defaults to "specdown/").
|
231
235
|
|
232
236
|
```sh
|
233
237
|
$ specdown test.markdown -r specdown_environment/
|
234
238
|
```
|
235
239
|
|
240
|
+
### Output Format
|
241
|
+
|
242
|
+
By default, `specdown` will output colorized terminal output. If you'd rather the output not be colorized, you can use the `-f terminal` switch:
|
243
|
+
|
244
|
+
```sh
|
245
|
+
$ specdown -f plain
|
246
|
+
```
|
247
|
+
|
248
|
+
The default format is `color`.
|
249
|
+
|
250
|
+
You can also configure the report format in your Ruby code:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
Specdown::Config.reporter = :terminal
|
254
|
+
```
|
255
|
+
|
256
|
+
Note that this defaults to `:color_terminal`. Also, please note that command line options take precedence.
|
257
|
+
|
236
258
|
## TODO
|
237
259
|
|
238
260
|
This library is still very new, but we are rapidly adding features to it. Here's what is on the immediate horizon:
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.6
|
data/features/command.feature
CHANGED
@@ -96,7 +96,6 @@ Feature: `specdown` command
|
|
96
96
|
"""
|
97
97
|
|
98
98
|
|
99
|
-
@focus
|
100
99
|
Scenario: `specdown` command invoked with a directory
|
101
100
|
Given I have a specdown directory 'specdown/tests' containing 3 markdown files, each with 1 passing test
|
102
101
|
When I run `specdown specdown/tests`
|
@@ -108,3 +107,14 @@ Feature: `specdown` command
|
|
108
107
|
3 tests
|
109
108
|
0 failures
|
110
109
|
"""
|
110
|
+
|
111
|
+
|
112
|
+
@focus
|
113
|
+
Scenario: -f terminal format switch
|
114
|
+
Given I am in a directory with a 'specdown' folder
|
115
|
+
When I run `specdown -f plain`
|
116
|
+
Then I should not see colorized output
|
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
|
@@ -4,16 +4,18 @@ Feature: Specdown::ReporterFactory
|
|
4
4
|
|
5
5
|
The `Specdown::ReporterFactory` has an API that allows you to configure new decorators for reports. Use the `Specdown::ReporterFactory.decorate` method:
|
6
6
|
|
7
|
-
Specdown::ReporterFactory.decorate do |
|
7
|
+
Specdown::ReporterFactory.decorate do |reporter|
|
8
8
|
if Specdown::Config.reporter == :color_terminal
|
9
|
-
|
9
|
+
reporter.extend MyDecoratorModule
|
10
10
|
end
|
11
|
+
|
12
|
+
reporter
|
11
13
|
end
|
12
14
|
|
13
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.
|
14
16
|
|
15
17
|
Specdown::Config.reporter = :color_terminal
|
16
|
-
Specdown::ReporterFactory.generate.
|
18
|
+
Specdown::ReporterFactory.generate.should be_kind_of(Specdown::AnsiColor)
|
17
19
|
|
18
20
|
|
19
21
|
Scenario: Adding a new decorator to Specdown::ReporterFactory
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Feature: Specdown::SandboxFactory
|
2
|
+
|
3
|
+
All of your tests run in a sandbox - a protected object namespace, configurable via a simple API.
|
4
|
+
|
5
|
+
For example, let's imagine we've written an assertion library called `SimpleAssert`:
|
6
|
+
|
7
|
+
module SimpleAssert
|
8
|
+
def simple_assert(&block)
|
9
|
+
raise "failed!" if block.call == false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
We can configure Specdown to include our library in the sandbox via the `Specdown::SandboxFactory.decorate` API:
|
14
|
+
|
15
|
+
Specdown::SandboxFactory.decorate do |sandbox|
|
16
|
+
sandbox.extend SimpleAssert
|
17
|
+
end
|
18
|
+
|
19
|
+
Now all sandboxes will respond to the `simple_assert` method. We could even make this configurable:
|
20
|
+
|
21
|
+
Specdown::SandboxFactory.decorate do |sandbox|
|
22
|
+
if Specdown::Config.expectations == :simple_assert
|
23
|
+
sandbox.extend SimpleAssert
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Now you could add `Specdown::Config.expectations = :simple_assert` to your `specdown/support/env.rb` to use your own SimpleAssert library in your tests.
|
28
|
+
|
29
|
+
|
30
|
+
Scenario: decorate sandbox with module
|
31
|
+
|
32
|
+
Given the following module:
|
33
|
+
"""
|
34
|
+
module SimpleAssert
|
35
|
+
def simple_assert(&block)
|
36
|
+
raise "failed!" if block.call == false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
|
41
|
+
When I decorate the sandbox with it:
|
42
|
+
"""
|
43
|
+
Specdown::SandboxFactory.decorate do |sandbox|
|
44
|
+
sandbox.extend SimpleAssert
|
45
|
+
end
|
46
|
+
"""
|
47
|
+
|
48
|
+
Then all sandboxes should include my module methods:
|
49
|
+
"""
|
50
|
+
proc {
|
51
|
+
Specdown::SandboxFactory.generate.instance_eval do
|
52
|
+
simple_assert { 1 == 1 }
|
53
|
+
end
|
54
|
+
}.should_not raise_exception
|
55
|
+
"""
|
@@ -0,0 +1 @@
|
|
1
|
+
Specdown::Config.reporter = :color_terminal
|
@@ -24,6 +24,22 @@ Given /^I have a specdown directory 'specdown\/tests' containing 3 markdown file
|
|
24
24
|
@directory = "features/specdown_examples/nested_directories_test/"
|
25
25
|
end
|
26
26
|
|
27
|
+
Given /^I am in a directory with a 'specdown' folder$/ do
|
28
|
+
@directory = "features/specdown_examples/format_switch_test/"
|
29
|
+
end
|
30
|
+
|
27
31
|
When /^I run `(.*)`$/ do |command|
|
28
32
|
@output = `cd #{@directory} && bundle exec ruby -I ../../../lib ../../../bin/#{command}`
|
29
33
|
end
|
34
|
+
|
35
|
+
Then /^I should not see colorized output$/ do
|
36
|
+
raise "Oops! Output is colorized!" if colorized?(@output)
|
37
|
+
end
|
38
|
+
|
39
|
+
Then /^I should see colorized output$/ do
|
40
|
+
raise "Oops! Output is not colorized!" unless colorized?(@output)
|
41
|
+
end
|
42
|
+
|
43
|
+
def colorized?(output)
|
44
|
+
output.include? "\e[1m"
|
45
|
+
end
|
@@ -16,10 +16,22 @@ module Specdown
|
|
16
16
|
Specdown::Config.root = root
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on '-
|
19
|
+
opts.on '-f', '--format plain|color', 'defaults to "color"' do |format|
|
20
|
+
case format
|
21
|
+
when 'plain' then Specdown::Config.reporter = :terminal
|
22
|
+
when 'color' then Specdown::Config.reporter = :color_terminal
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on_tail '-h', '--help', 'Display this screen' do
|
20
27
|
puts opts
|
21
28
|
exit
|
22
29
|
end
|
30
|
+
|
31
|
+
opts.on_tail "-v", "--version", "Show version" do
|
32
|
+
puts File.read(File.join(File.dirname(__FILE__), "../../../VERSION"))
|
33
|
+
exit
|
34
|
+
end
|
23
35
|
end
|
24
36
|
end
|
25
37
|
end
|
data/lib/specdown/command.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
Specdown::SandboxFactory.decorate do |sandbox|
|
2
|
+
if Specdown::Config.expectations.nil?
|
3
|
+
begin
|
4
|
+
require 'rspec/expectations'
|
5
|
+
sandbox.extend ::RSpec::Matchers
|
6
|
+
rescue LoadError => e
|
7
|
+
require 'test/unit/assertions'
|
8
|
+
sandbox.extend ::Test::Unit::Assertions
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -4,53 +4,19 @@ module Specdown
|
|
4
4
|
|
5
5
|
def generate
|
6
6
|
Module.new {}.tap do |sandbox|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
private
|
12
|
-
def setup_expectation_library
|
13
|
-
expectation_library_setups[Config.expectations]
|
14
|
-
end
|
15
|
-
|
16
|
-
def expectation_library_setups
|
17
|
-
Hash.new(default_expectations_setup).tap do |setups|
|
18
|
-
setups[:rspec] = rspec_expectations_setup
|
19
|
-
setups[:test_unit] = test_unit_expectations_setup
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def rspec_installed?
|
24
|
-
require_rspec
|
25
|
-
end
|
26
|
-
|
27
|
-
def require_rspec
|
28
|
-
begin
|
29
|
-
require('rspec/expectations')
|
30
|
-
true
|
31
|
-
rescue LoadError
|
32
|
-
false
|
7
|
+
decorators.each do |decorator|
|
8
|
+
decorator.call sandbox
|
9
|
+
end
|
33
10
|
end
|
34
11
|
end
|
35
12
|
|
36
|
-
def
|
37
|
-
|
38
|
-
rspec_expectations_setup
|
39
|
-
else
|
40
|
-
test_unit_expectations_setup
|
41
|
-
end
|
13
|
+
def decorate(&block)
|
14
|
+
decorators << block
|
42
15
|
end
|
43
16
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_unit_expectations_setup
|
50
|
-
proc do |sandbox|
|
51
|
-
require 'test/unit/assertions'
|
52
|
-
sandbox.extend ::Test::Unit::Assertions
|
53
|
-
end
|
17
|
+
private
|
18
|
+
def decorators
|
19
|
+
@decorators ||= []
|
54
20
|
end
|
55
21
|
end
|
56
22
|
end
|
data/lib/specdown.rb
CHANGED
@@ -28,3 +28,6 @@ require 'specdown/runner/report_summary'
|
|
28
28
|
require 'specdown/runner/exception_facade'
|
29
29
|
require 'specdown/reporter/terminal_reporter'
|
30
30
|
require 'specdown/reporter/color_terminal_reporter'
|
31
|
+
require 'specdown/sandbox_decorators/default_assertion_library'
|
32
|
+
require 'specdown/sandbox_decorators/rspec_expectations'
|
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
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
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-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: kramdown
|
@@ -87,6 +87,7 @@ extra_rdoc_files:
|
|
87
87
|
- CHANGELOG.markdown
|
88
88
|
- README.markdown
|
89
89
|
files:
|
90
|
+
- VERSION
|
90
91
|
- lib/specdown/command/option_parser.rb
|
91
92
|
- lib/specdown/command.rb
|
92
93
|
- lib/specdown/config.rb
|
@@ -110,6 +111,9 @@ files:
|
|
110
111
|
- lib/specdown/runner/reporter.rb
|
111
112
|
- lib/specdown/runner/stats.rb
|
112
113
|
- lib/specdown/runner.rb
|
114
|
+
- lib/specdown/sandbox_decorators/default_assertion_library.rb
|
115
|
+
- lib/specdown/sandbox_decorators/rspec_expectations.rb
|
116
|
+
- lib/specdown/sandbox_decorators/test_unit_assertions.rb
|
113
117
|
- lib/specdown/sandbox_factory.rb
|
114
118
|
- lib/specdown/specdown.rb
|
115
119
|
- lib/specdown/templates/color_summary.erb
|
@@ -130,6 +134,7 @@ files:
|
|
130
134
|
- features/reporter.feature
|
131
135
|
- features/reporter_factory.feature
|
132
136
|
- features/runner.feature
|
137
|
+
- features/sandbox_factory.feature
|
133
138
|
- features/specdown_examples/after_hooks/specdown/env.rb
|
134
139
|
- features/specdown_examples/after_hooks/specdown/hooks.rb
|
135
140
|
- features/specdown_examples/after_hooks/specdown/parser_example.markdown
|
@@ -139,6 +144,7 @@ files:
|
|
139
144
|
- features/specdown_examples/before_hooks/specdown/env.rb
|
140
145
|
- features/specdown_examples/before_hooks/specdown/hooks.rb
|
141
146
|
- features/specdown_examples/before_hooks/specdown/parser_example.markdown
|
147
|
+
- features/specdown_examples/format_switch_test/specdown/env.rb
|
142
148
|
- features/specdown_examples/nested_directories_test/specdown/env.rb
|
143
149
|
- features/specdown_examples/nested_directories_test/specdown/tests/1.markdown
|
144
150
|
- features/specdown_examples/nested_directories_test/specdown/tests/2.markdown
|
@@ -163,6 +169,7 @@ files:
|
|
163
169
|
- features/step_definitions/reporter.rb
|
164
170
|
- features/step_definitions/reporter_factory.rb
|
165
171
|
- features/step_definitions/runner.rb
|
172
|
+
- features/step_definitions/sandbox_factory.rb
|
166
173
|
- features/support/env.rb
|
167
174
|
- features/support/hooks.rb
|
168
175
|
homepage: http://github.com/moonmaster9000/specdown
|
@@ -210,6 +217,7 @@ test_files:
|
|
210
217
|
- features/reporter.feature
|
211
218
|
- features/reporter_factory.feature
|
212
219
|
- features/runner.feature
|
220
|
+
- features/sandbox_factory.feature
|
213
221
|
- features/specdown_examples/after_hooks/specdown/env.rb
|
214
222
|
- features/specdown_examples/after_hooks/specdown/hooks.rb
|
215
223
|
- features/specdown_examples/after_hooks/specdown/parser_example.markdown
|
@@ -219,6 +227,7 @@ test_files:
|
|
219
227
|
- features/specdown_examples/before_hooks/specdown/env.rb
|
220
228
|
- features/specdown_examples/before_hooks/specdown/hooks.rb
|
221
229
|
- features/specdown_examples/before_hooks/specdown/parser_example.markdown
|
230
|
+
- features/specdown_examples/format_switch_test/specdown/env.rb
|
222
231
|
- features/specdown_examples/nested_directories_test/specdown/env.rb
|
223
232
|
- features/specdown_examples/nested_directories_test/specdown/tests/1.markdown
|
224
233
|
- features/specdown_examples/nested_directories_test/specdown/tests/2.markdown
|
@@ -243,5 +252,6 @@ test_files:
|
|
243
252
|
- features/step_definitions/reporter.rb
|
244
253
|
- features/step_definitions/reporter_factory.rb
|
245
254
|
- features/step_definitions/runner.rb
|
255
|
+
- features/step_definitions/sandbox_factory.rb
|
246
256
|
- features/support/env.rb
|
247
257
|
- features/support/hooks.rb
|