snapdragon 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +5 -0
- data/README.markdown +43 -18
- data/bin/snapdragon +1 -1
- data/bin/snapdragon_server +1 -1
- data/example/spec/bar_spec.js +1 -0
- data/example/spec/hoopty_spec.js +1 -1
- data/example/spec_helper.js +2 -0
- data/lib/snapdragon/file_base.rb +45 -0
- data/lib/snapdragon/path.rb +3 -3
- data/lib/snapdragon/spec_file.rb +4 -25
- data/lib/snapdragon/suite.rb +20 -6
- data/lib/snapdragon/version.rb +1 -1
- data/lib/snapdragon/views/run.erb +1 -1
- data/lib/snapdragon/web_application.rb +4 -4
- data/spec/lib/snapdragon/suite_spec.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c647d99a8ff9d5901d9f04c740dbcd44a69d2ed
|
4
|
+
data.tar.gz: 2dd56c5c44b89a6c095177f6d6c76e3ee8e42902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a5ed874e835d8eab0b2c7dafb93589fcb1fbeacd140422548b7e7b68e4d3e2c567d8ecc1cbd7179ef85f218c56c2dd82eaa4372bf10e55dea947c0e8487df1b
|
7
|
+
data.tar.gz: 5ea832633662226599029731286da72d534c48e21d4e637afff8b463af19509fc1bd6084dbab3442153364d96bafc615a5639b2fc2fa572c51c4dad03dddbcbd
|
data/ChangeLog.markdown
CHANGED
@@ -6,6 +6,11 @@ versions as well as provide a rough history.
|
|
6
6
|
|
7
7
|
#### Next Release
|
8
8
|
|
9
|
+
#### v0.1.7
|
10
|
+
|
11
|
+
* made require_relative directives work inside of required files
|
12
|
+
([\#15](http://github.com/reachlocal/snapdragon/issues/15))
|
13
|
+
|
9
14
|
#### v0.1.6
|
10
15
|
|
11
16
|
* snapdragon_server when given `some/spec.js:344` now opens the browser to the
|
data/README.markdown
CHANGED
@@ -6,15 +6,21 @@
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```
|
10
|
+
gem 'snapdragon'
|
11
|
+
```
|
10
12
|
|
11
13
|
And then execute:
|
12
14
|
|
13
|
-
|
15
|
+
```text
|
16
|
+
$ bundle
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
20
|
|
17
|
-
|
21
|
+
```text
|
22
|
+
$ gem install snapdragon
|
23
|
+
```
|
18
24
|
|
19
25
|
## Install PhantomJS
|
20
26
|
|
@@ -28,7 +34,9 @@ I recommend installing [PhantomJS](http://phantomjs.org/) using
|
|
28
34
|
[Homebrew](http://mxcl.github.io/homebrew/) it can be installed as easily as
|
29
35
|
running the following command:
|
30
36
|
|
31
|
-
|
37
|
+
```text
|
38
|
+
$ brew install phantomjs
|
39
|
+
```
|
32
40
|
|
33
41
|
## Quick Start Guide
|
34
42
|
|
@@ -105,26 +113,30 @@ examples.
|
|
105
113
|
The following runs the describe or it block that corresponds to line number
|
106
114
|
*23* in the *spec/javascript/foo_spec.js* file.
|
107
115
|
|
108
|
-
```
|
109
|
-
snapdragon spec/javascript/foo_spec.js:23
|
116
|
+
```text
|
117
|
+
$ snapdragon spec/javascript/foo_spec.js:23
|
110
118
|
```
|
111
119
|
|
112
120
|
#### Run an entire spec file(s)
|
113
121
|
|
114
|
-
```
|
115
|
-
snapdragon spec/javascript/foo_spec.js spec/javascript/bar_spec.js
|
122
|
+
```text
|
123
|
+
$ snapdragon spec/javascript/foo_spec.js spec/javascript/bar_spec.js
|
116
124
|
```
|
117
125
|
|
118
126
|
#### Run an entire directory of spec files
|
119
127
|
|
120
|
-
|
121
|
-
|
128
|
+
The following recursively explores the given directories contents for
|
129
|
+
files that end in `spec.js` or `Spec.js` and runs the tests in the identified
|
130
|
+
spec files.
|
131
|
+
|
132
|
+
```text
|
133
|
+
$ snapdragon spec/javascripts
|
122
134
|
```
|
123
135
|
|
124
136
|
#### Run combination of files and directories
|
125
137
|
|
126
|
-
```
|
127
|
-
snapdragon spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
138
|
+
```text
|
139
|
+
$ snapdragon spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
128
140
|
```
|
129
141
|
|
130
142
|
## Usage (snapdragon_server)
|
@@ -137,22 +149,35 @@ useful if you want to debug some JavaScript as your browser most likely has a
|
|
137
149
|
JavaScript debugger built into it. A few examples of this commands usage
|
138
150
|
follow.
|
139
151
|
|
140
|
-
#### Run specific
|
152
|
+
#### Run a specific describe/it block
|
141
153
|
|
154
|
+
The following runs the describe or it block that corresponds to line number
|
155
|
+
*23* in the *spec/javascript/foo_spec.js* file.
|
156
|
+
|
157
|
+
```text
|
158
|
+
$ snapdragon_server spec/javascript/foo_spec.js:23
|
142
159
|
```
|
143
|
-
|
160
|
+
|
161
|
+
#### Run specific spec files
|
162
|
+
|
163
|
+
```text
|
164
|
+
$ snapdragon_server spec/javascript/foo_spec.js spec/javascript/bar_spec.js
|
144
165
|
```
|
145
166
|
|
146
167
|
#### Run all the specs in directories
|
147
168
|
|
148
|
-
|
149
|
-
|
169
|
+
The following recursively explores the given directories contents for
|
170
|
+
files that end in `spec.js` or `Spec.js` and runs the tests in the identified
|
171
|
+
spec files.
|
172
|
+
|
173
|
+
```text
|
174
|
+
$ snapdragon_server spec/javascript custom_js/specs
|
150
175
|
```
|
151
176
|
|
152
177
|
#### Combine files and directories
|
153
178
|
|
154
|
-
```
|
155
|
-
snapdragon_server spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
179
|
+
```text
|
180
|
+
$ snapdragon_server spec/javascript custom_js/tests/foo_spec.js custom_js/test/bar_spec.js
|
156
181
|
```
|
157
182
|
|
158
183
|
## // require_relative() directive
|
data/bin/snapdragon
CHANGED
data/bin/snapdragon_server
CHANGED
data/example/spec/bar_spec.js
CHANGED
data/example/spec/hoopty_spec.js
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative './path'
|
2
|
+
|
3
|
+
module Snapdragon
|
4
|
+
class FileBase
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
end
|
8
|
+
|
9
|
+
def relative_url_path
|
10
|
+
::File.join('/', @path.path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def require_paths
|
14
|
+
f = ::File.open(::File.expand_path(@path.path), 'r')
|
15
|
+
lines = f.readlines
|
16
|
+
f.close
|
17
|
+
|
18
|
+
require_paths = []
|
19
|
+
|
20
|
+
lines.each do |line|
|
21
|
+
if line =~ /\/\/+\s+require_relative\(['"](.+)['"]\)\s+$/
|
22
|
+
require_paths << ::File.join(::File.dirname(@path.path), $1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
return require_paths
|
27
|
+
end
|
28
|
+
|
29
|
+
def require_files
|
30
|
+
files = []
|
31
|
+
require_paths.each do |require_path|
|
32
|
+
files << Snapdragon::RequireFile.new(Snapdragon::Path.new(require_path))
|
33
|
+
end
|
34
|
+
return files
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# I was getting some weirdness I think because of Cyclic Requires between
|
40
|
+
# require_file.rb and file_base.rb so I simply moved require_file.rb content
|
41
|
+
# into file_base.rb and it seemed to resolve it.
|
42
|
+
module Snapdragon
|
43
|
+
class RequireFile < Snapdragon::FileBase
|
44
|
+
end
|
45
|
+
end
|
data/lib/snapdragon/path.rb
CHANGED
@@ -21,7 +21,7 @@ module Snapdragon
|
|
21
21
|
spec_dir = Snapdragon::SpecDirectory.new(self)
|
22
22
|
return spec_dir.spec_files
|
23
23
|
else
|
24
|
-
return [SpecFile.new(self)]
|
24
|
+
return [Snapdragon::SpecFile.new(self)]
|
25
25
|
end
|
26
26
|
end
|
27
27
|
return []
|
@@ -35,11 +35,11 @@ module Snapdragon
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def is_a_directory?
|
38
|
-
return File.directory?(@path)
|
38
|
+
return ::File.directory?(@path)
|
39
39
|
end
|
40
40
|
|
41
41
|
def exists?
|
42
|
-
return File.exists?(@path)
|
42
|
+
return ::File.exists?(@path)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/lib/snapdragon/spec_file.rb
CHANGED
@@ -1,29 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def initialize(path)
|
4
|
-
@path = path
|
5
|
-
end
|
6
|
-
|
7
|
-
def relative_url_path
|
8
|
-
File.join('/', @path.path)
|
9
|
-
end
|
10
|
-
|
11
|
-
def require_paths
|
12
|
-
f = File.open(File.expand_path(@path.path), 'r')
|
13
|
-
lines = f.readlines
|
14
|
-
f.close
|
15
|
-
|
16
|
-
require_paths = []
|
17
|
-
|
18
|
-
lines.each do |line|
|
19
|
-
if line =~ /\/\/+\s+require_relative\(['"](.+)['"]\)\s+$/
|
20
|
-
require_paths << File.join('/', File.join(File.dirname(@path.path), $1))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
return require_paths
|
25
|
-
end
|
1
|
+
require_relative './file_base'
|
2
|
+
require_relative './path'
|
26
3
|
|
4
|
+
module Snapdragon
|
5
|
+
class SpecFile < Snapdragon::FileBase
|
27
6
|
def filtered?
|
28
7
|
return @path.has_line_number?
|
29
8
|
end
|
data/lib/snapdragon/suite.rb
CHANGED
@@ -17,14 +17,17 @@ module Snapdragon
|
|
17
17
|
return spec_file_objs
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def require_files
|
21
|
+
return get_require_files_from_files(spec_files)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
def require_file_relative_url_paths
|
25
|
+
paths = Set.new
|
26
|
+
require_files.each do |file|
|
27
|
+
paths << file.relative_url_path
|
25
28
|
end
|
26
|
-
|
27
|
-
return
|
29
|
+
puts "DREW: paths = #{paths.inspect}"
|
30
|
+
return paths
|
28
31
|
end
|
29
32
|
|
30
33
|
def filtered?
|
@@ -40,5 +43,16 @@ module Snapdragon
|
|
40
43
|
end
|
41
44
|
return ''
|
42
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def get_require_files_from_files(files)
|
50
|
+
req_files = []
|
51
|
+
files.each do |file|
|
52
|
+
req_files.concat(get_require_files_from_files(file.require_files))
|
53
|
+
req_files.concat(file.require_files)
|
54
|
+
end
|
55
|
+
return req_files
|
56
|
+
end
|
43
57
|
end
|
44
58
|
end
|
data/lib/snapdragon/version.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
<script type="text/javascript" src="/resources/SnapdragonConsoleReporter.js"></script>
|
6
6
|
|
7
7
|
<!-- The implementation code the spec files being tested need -->
|
8
|
-
<% @suite.
|
8
|
+
<% @suite.require_file_relative_url_paths.each do |path| %>
|
9
9
|
<script type="text/javascript" src="<%= path %>"></script>
|
10
10
|
<% end %>
|
11
11
|
|
@@ -4,7 +4,7 @@ require 'erb'
|
|
4
4
|
module Snapdragon
|
5
5
|
class WebApplication < Sinatra::Base
|
6
6
|
set :static, false
|
7
|
-
set :root, File.expand_path('.', File.dirname(__FILE__))
|
7
|
+
set :root, ::File.expand_path('.', ::File.dirname(__FILE__))
|
8
8
|
|
9
9
|
def initialize(app = nil, suite)
|
10
10
|
super()
|
@@ -16,15 +16,15 @@ module Snapdragon
|
|
16
16
|
end
|
17
17
|
|
18
18
|
get "/jasmine-core/*" do |path|
|
19
|
-
send_file File.expand_path(File.join('../jasmine/lib/jasmine-core', path), File.dirname(__FILE__))
|
19
|
+
send_file ::File.expand_path(::File.join('../jasmine/lib/jasmine-core', path), ::File.dirname(__FILE__))
|
20
20
|
end
|
21
21
|
|
22
22
|
get "/resources/*" do |path|
|
23
|
-
send_file File.expand_path(File.join('resources', path), File.dirname(__FILE__))
|
23
|
+
send_file ::File.expand_path(::File.join('resources', path), ::File.dirname(__FILE__))
|
24
24
|
end
|
25
25
|
|
26
26
|
get "/*" do |path|
|
27
|
-
send_file File.expand_path(File.join('.', path))
|
27
|
+
send_file ::File.expand_path(::File.join('.', path))
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
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.1.
|
4
|
+
version: 0.1.7
|
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-06-
|
11
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -133,9 +133,11 @@ files:
|
|
133
133
|
- bin/snapdragon_server
|
134
134
|
- example/spec/bar_spec.js
|
135
135
|
- example/spec/hoopty_spec.js
|
136
|
+
- example/spec_helper.js
|
136
137
|
- example/src/hoopty.js
|
137
138
|
- lib/snapdragon.rb
|
138
139
|
- lib/snapdragon/cli_application.rb
|
140
|
+
- lib/snapdragon/file_base.rb
|
139
141
|
- lib/snapdragon/path.rb
|
140
142
|
- lib/snapdragon/resources/.gitkeep
|
141
143
|
- lib/snapdragon/resources/SnapdragonConsoleReporter.js
|