snapdragon 0.1.12 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +6 -0
- data/README.markdown +99 -5
- data/lib/snapdragon/command_line_parser.rb +3 -2
- data/lib/snapdragon/suite.rb +6 -1
- data/lib/snapdragon/version.rb +1 -1
- data/spec/lib/snapdragon/command_line_parser_spec.rb +13 -1
- data/spec/lib/snapdragon/suite_spec.rb +56 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d91d70e71200c4c41242a3578bde16b234a52152
|
4
|
+
data.tar.gz: 4c01baa008019b3ed66a4e54330e402eaa94d44e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 081c307e74c3e70e385e425109c28617375c2cc2f4c91f450e7d93b4770de71cda1be26c1795779f774bb345815095279bb41538604494d7d4b62fbafa38716d
|
7
|
+
data.tar.gz: 3cef1deb3c500497ab3bf8f9750ec9a8bdd59e0b6ae30dc34a5e56a29afcced0c12b53ef475c7208356f87b956f92f047d72b1b9364aa3532515ba62f12ed23f
|
data/ChangeLog.markdown
CHANGED
@@ -6,6 +6,12 @@ versions as well as provide a rough history.
|
|
6
6
|
|
7
7
|
#### Next Release
|
8
8
|
|
9
|
+
#### v0.2.0
|
10
|
+
|
11
|
+
* added -P, --pattern options to over the test file search pattern as well as
|
12
|
+
a default test file search pattern when not given an explicit file or
|
13
|
+
directory path.
|
14
|
+
|
9
15
|
#### v0.1.12
|
10
16
|
|
11
17
|
* add the --color, --no-color, --colour, --no-colour, and -c option to
|
data/README.markdown
CHANGED
@@ -41,10 +41,10 @@ $ brew install phantomjs
|
|
41
41
|
## Quick Start Guide
|
42
42
|
|
43
43
|
If you are a visual learner Brian Miller and I have put together a Free
|
44
|
-
[Snapdragon](http://
|
44
|
+
[Snapdragon Screencast](http://codebreakdown.com/screencasts/7) at [The Code
|
45
45
|
Breakdown](http://codebreakdown.com).
|
46
46
|
|
47
|
-
[![It in Action](http://media.codebreakdown.com/thumbnails/tcb-0007-thumbnail-400x225.png)](http://codebreakdown.com)
|
47
|
+
[![It in Action](http://media.codebreakdown.com/thumbnails/tcb-0007-thumbnail-400x225.png)](http://codebreakdown.com/screencasts/7)
|
48
48
|
|
49
49
|
For those of you that like to jump right in and start playing with new tools
|
50
50
|
follow the steps below to get started.
|
@@ -138,6 +138,30 @@ $ snapdragon spec/javascripts
|
|
138
138
|
$ snapdragon spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
139
139
|
```
|
140
140
|
|
141
|
+
#### Run test files matched by default pattern (`spec/**/*_spec.js`)
|
142
|
+
|
143
|
+
```text
|
144
|
+
$ snapdragon
|
145
|
+
```
|
146
|
+
|
147
|
+
#### Run test files matched by custom pattern
|
148
|
+
|
149
|
+
The following is an example command that specifies a custom pattern to use to
|
150
|
+
match test files to run. Please note the double quote marks around the
|
151
|
+
pattern. These are necessary as without them most shells will try and resolve
|
152
|
+
the pattern for you. Further details on the glob syntax can be found
|
153
|
+
[here](http://ruby-doc.org/core-2.0.0/Dir.html#method-c-glob).
|
154
|
+
|
155
|
+
```text
|
156
|
+
$ snapdragon -P "spec/assets/javascripts/foo/*_spec.js"
|
157
|
+
```
|
158
|
+
|
159
|
+
#### Output Usage Details/Help
|
160
|
+
|
161
|
+
```text
|
162
|
+
$ snapdragon --help
|
163
|
+
```
|
164
|
+
|
141
165
|
## Usage (snapdragon_server)
|
142
166
|
|
143
167
|
The *snapdragon_server* command allows you to run your
|
@@ -157,13 +181,13 @@ The following runs the describe or it block that corresponds to line number
|
|
157
181
|
$ snapdragon_server spec/javascript/foo_spec.js:23
|
158
182
|
```
|
159
183
|
|
160
|
-
#### Run
|
184
|
+
#### Run an entire spec file(s)
|
161
185
|
|
162
186
|
```text
|
163
187
|
$ snapdragon_server spec/javascript/foo_spec.js spec/javascript/bar_spec.js
|
164
188
|
```
|
165
189
|
|
166
|
-
#### Run
|
190
|
+
#### Run an entire directory of spec files
|
167
191
|
|
168
192
|
The following recursively explores the given directories contents for
|
169
193
|
files that end in `spec.js` or `Spec.js` and runs the tests in the identified
|
@@ -173,12 +197,82 @@ spec files.
|
|
173
197
|
$ snapdragon_server spec/javascript custom_js/specs
|
174
198
|
```
|
175
199
|
|
176
|
-
####
|
200
|
+
#### Run combination of files and directories
|
177
201
|
|
178
202
|
```text
|
179
203
|
$ snapdragon_server spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
180
204
|
```
|
181
205
|
|
206
|
+
#### Run test files matched by default pattern (`spec/**/*_spec.js`)
|
207
|
+
|
208
|
+
```text
|
209
|
+
$ snapdragon_server
|
210
|
+
```
|
211
|
+
|
212
|
+
#### Run test files matched by custom pattern
|
213
|
+
|
214
|
+
The following is an example command that specifies a custom pattern to use to
|
215
|
+
match test files to run. Please note the double quote marks around the
|
216
|
+
pattern. These are necessary as without them most shells will try and resolve
|
217
|
+
the pattern for you. Further details on the glob syntax can be found
|
218
|
+
[here](http://ruby-doc.org/core-2.0.0/Dir.html#method-c-glob).
|
219
|
+
|
220
|
+
```text
|
221
|
+
$ snapdragon_server -P "spec/assets/javascripts/foo/*_spec.js"
|
222
|
+
```
|
223
|
+
|
224
|
+
#### Output Usage Details/Help
|
225
|
+
|
226
|
+
```text
|
227
|
+
$ snapdragon_server --help
|
228
|
+
```
|
229
|
+
|
230
|
+
### Additional Options
|
231
|
+
|
232
|
+
Below is a listing of the various options that can be passed to either the
|
233
|
+
`snapdragon` or `snapdragon_server` commands.
|
234
|
+
|
235
|
+
#### Version (`-v`, `--version`)
|
236
|
+
|
237
|
+
When given this option it will output the version that you are using
|
238
|
+
and exit without running any tests.
|
239
|
+
|
240
|
+
#### Help (`-h`, `--help`)
|
241
|
+
|
242
|
+
When given this option it will output basic usage summary and exit without
|
243
|
+
running any tests.
|
244
|
+
|
245
|
+
#### Format (`-f FORMAT`, `--format FORMAT`)
|
246
|
+
|
247
|
+
This option allows you to specify the output format of the tests. By default
|
248
|
+
it outputs using the `console` format. This option is extremely useful when
|
249
|
+
you would like to use `snapdragon` inside of a CI process because you can
|
250
|
+
instruct it to output in other formats such as `junit` which CI services
|
251
|
+
can parse.
|
252
|
+
|
253
|
+
The following are the currently supported `FORMAT` values.
|
254
|
+
|
255
|
+
* `console` (default)
|
256
|
+
* `junit`
|
257
|
+
|
258
|
+
#### Color (`--no-color`, `--no-colour`)
|
259
|
+
|
260
|
+
If you would like to disable ANSI color output which is enabled by default,
|
261
|
+
include either the `--no-color` or `--no-colour` option.
|
262
|
+
|
263
|
+
#### Pattern (`-P PATTERN`, `--pattern PATTERN`)
|
264
|
+
|
265
|
+
When this option is not given and no file or directory paths are given it
|
266
|
+
uses the default pattern `"spec/**/*_spec.js"`.
|
267
|
+
|
268
|
+
When given this option without any explicit file paths or directory paths it
|
269
|
+
will use the provided glob pattern to identify which test files to run. Any
|
270
|
+
example usage of this option can be seen above in the *Run test files matched
|
271
|
+
by custom pattern* section. For more details on the glob pattern syntax please
|
272
|
+
refer to the [Ruby
|
273
|
+
Dir.glob](http://ruby-doc.org/core-2.0.0/Dir.html#method-c-glob)
|
274
|
+
documentation.
|
275
|
+
|
182
276
|
## // require_relative() directive
|
183
277
|
|
184
278
|
Snapdragon also provides a `// require_relative()` directive that the
|
@@ -8,6 +8,7 @@ module Snapdragon
|
|
8
8
|
options = OpenStruct.new
|
9
9
|
options.format = "console"
|
10
10
|
options.color = true
|
11
|
+
options.pattern = "spec/**/*_spec.js"
|
11
12
|
|
12
13
|
opts = OptionParser.new do |opts|
|
13
14
|
opts.banner = "Usage: snapdragon [options] [files or directories]"
|
@@ -23,8 +24,8 @@ module Snapdragon
|
|
23
24
|
opts.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output.') do |o|
|
24
25
|
options.color = o
|
25
26
|
end
|
26
|
-
|
27
|
-
|
27
|
+
opts.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec/**/*_spec.js").') do |pattern|
|
28
|
+
options.pattern = pattern
|
28
29
|
end
|
29
30
|
end
|
30
31
|
opts.parse!(args)
|
data/lib/snapdragon/suite.rb
CHANGED
@@ -15,10 +15,15 @@ module Snapdragon
|
|
15
15
|
@options.color
|
16
16
|
end
|
17
17
|
|
18
|
+
def pattern
|
19
|
+
@options.pattern
|
20
|
+
end
|
21
|
+
|
18
22
|
def spec_files
|
19
23
|
spec_file_objs = []
|
20
24
|
|
21
|
-
@paths
|
25
|
+
@paths << Dir[pattern] if @paths.empty?
|
26
|
+
@paths.flatten.uniq.each do |raw_path|
|
22
27
|
path = Snapdragon::Path.new(raw_path)
|
23
28
|
spec_file_objs.concat(path.spec_files)
|
24
29
|
end
|
data/lib/snapdragon/version.rb
CHANGED
@@ -25,7 +25,7 @@ describe Snapdragon::CommandLineParser do
|
|
25
25
|
|
26
26
|
context "no args supplied" do
|
27
27
|
it "exit" do
|
28
|
-
lambda { hide_stdout { subject.parse([]) } }.
|
28
|
+
lambda { hide_stdout { subject.parse([]) } }.should_not raise_error(SystemExit)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -58,5 +58,17 @@ describe Snapdragon::CommandLineParser do
|
|
58
58
|
subject.parse(["--no-color", "spec/hello_spec.rb"]).color.should eq false
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
context "when pattern is provided" do
|
63
|
+
it "sets the pattern value" do
|
64
|
+
subject.parse(["--pattern", "spec/*/*_test.js"]).pattern.should eq "spec/*/*_test.js"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when pattern is not provided" do
|
69
|
+
it "defaults to 'spec/**/*_spec.js'" do
|
70
|
+
subject.parse([]).pattern.should eq "spec/**/*_spec.js"
|
71
|
+
end
|
72
|
+
end
|
61
73
|
end
|
62
74
|
end
|
@@ -41,24 +41,64 @@ describe Snapdragon::Suite do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe "#
|
45
|
-
it "
|
46
|
-
|
47
|
-
|
48
|
-
suite = Snapdragon::Suite.new(options,
|
49
|
-
|
50
|
-
Snapdragon::Path.should_receive(:new).with('path_b_str').and_return(stub(spec_files: []))
|
51
|
-
suite.spec_files
|
44
|
+
describe "#pattern" do
|
45
|
+
it "returns the configured pattern setting" do
|
46
|
+
pattern = stub
|
47
|
+
options = stub(pattern: pattern)
|
48
|
+
suite = Snapdragon::Suite.new(options, stub)
|
49
|
+
suite.pattern.should eq pattern
|
52
50
|
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#spec_files" do
|
54
|
+
context "when paths are provided" do
|
55
|
+
it "does not read pattern from options" do
|
56
|
+
pattern = stub
|
57
|
+
options = stub(pattern: pattern)
|
58
|
+
paths = ['path_a_str', 'path_b_str']
|
59
|
+
suite = Snapdragon::Suite.new(options, paths)
|
60
|
+
suite.should_not_receive(:pattern)
|
61
|
+
suite.spec_files
|
62
|
+
end
|
63
|
+
|
64
|
+
it "creates a path object to represent the path" do
|
65
|
+
options = stub
|
66
|
+
paths = ['path_a_str', 'path_b_str']
|
67
|
+
suite = Snapdragon::Suite.new(options, paths)
|
68
|
+
Snapdragon::Path.should_receive(:new).with('path_a_str').and_return(stub(spec_files: []))
|
69
|
+
Snapdragon::Path.should_receive(:new).with('path_b_str').and_return(stub(spec_files: []))
|
70
|
+
suite.spec_files
|
71
|
+
end
|
53
72
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
73
|
+
it "returns the collection of the spec files of all of the paths" do
|
74
|
+
options = stub
|
75
|
+
paths = ['path_a_str', 'path_b_str']
|
76
|
+
suite = Snapdragon::Suite.new(options, paths)
|
77
|
+
spec_file_a = stub('spec_file_a'), spec_file_b = stub('spec_file_b')
|
78
|
+
Snapdragon::Path.stub(:new).with('path_a_str').and_return(stub(spec_files: [spec_file_a]))
|
79
|
+
Snapdragon::Path.stub(:new).with('path_b_str').and_return(stub(spec_files: [spec_file_b]))
|
80
|
+
suite.spec_files.should eq([spec_file_a, spec_file_b])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when paths are empty" do
|
85
|
+
it "reads the pattern from the options" do
|
86
|
+
pattern = stub
|
87
|
+
options = stub(pattern: pattern)
|
88
|
+
suite = Snapdragon::Suite.new(options, [])
|
89
|
+
suite.should_receive(:pattern).and_return(pattern)
|
90
|
+
suite.spec_files
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns the collection of spec files matching the pattern" do
|
94
|
+
pattern = stub
|
95
|
+
options = stub(pattern: pattern)
|
96
|
+
Dir.stub!(:[]) { ['path_c_str'] }
|
97
|
+
suite = Snapdragon::Suite.new(options, [])
|
98
|
+
spec_file_c = stub('spec_file_c')
|
99
|
+
Snapdragon::Path.stub(:new).with('path_c_str').and_return(stub(spec_files: [spec_file_c]))
|
100
|
+
suite.spec_files.should eq([spec_file_c])
|
101
|
+
end
|
62
102
|
end
|
63
103
|
end
|
64
104
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapdragon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew De Ponte
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|