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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1632da8263c3d4445832f76e9cc084c863946f2
4
- data.tar.gz: 6abc0912510a43f966bdcd5a2092398f76255923
3
+ metadata.gz: 8c647d99a8ff9d5901d9f04c740dbcd44a69d2ed
4
+ data.tar.gz: 2dd56c5c44b89a6c095177f6d6c76e3ee8e42902
5
5
  SHA512:
6
- metadata.gz: 0245feb11ac0d4a2bc8b6e9ba1f04b45f24be9635c18bd12c7b27df683f5a9d0ff9d5824d8858cd93a49de00ecb989ab7e94c0b39ca9d9a98e5f601ecd5da8e8
7
- data.tar.gz: a295d969bf7ff0f5e0f4bcd86c6bd9dd46deec98d3fecd09c6867031e6de83f4c4ba7a32727136f5184b01d32c7c89a512d63adabf0ec42449baac4a3c1f33d7
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
- gem 'snapdragon'
9
+ ```
10
+ gem 'snapdragon'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ ```text
16
+ $ bundle
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
- $ gem install snapdragon
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
- $ brew install phantomjs
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
- snapdragon spec/javascripts
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 spec files
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
- snapdragon_server spec/javascript/foo_spec.js spec/javascript/bar_spec.js
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
- snapdragon_server spec/javascript custom_js/specs
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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/../lib')
4
4
 
5
5
  require 'rubygems'
6
6
  require 'snapdragon/cli_application'
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/../lib')
4
4
 
5
5
  require 'rubygems'
6
6
  require 'snapdragon/cli_application'
@@ -1,3 +1,4 @@
1
+ // require_relative('../spec_helper.js')
1
2
 
2
3
  describe("Bar", function() {
3
4
  it(".foo", function() {
@@ -1,4 +1,4 @@
1
- // require_relative('../src/hoopty.js')
1
+ // require_relative('../spec_helper.js')
2
2
 
3
3
  // This is just some example Jasmine spec code to test that everything would
4
4
  // work assuming that I can find a way to get the spec code loaded in here
@@ -0,0 +1,2 @@
1
+ // require_relative('src/hoopty.js')
2
+ // require_relative('./src/hoopty.js')
@@ -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
@@ -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
@@ -1,29 +1,8 @@
1
- module Snapdragon
2
- class SpecFile
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
@@ -17,14 +17,17 @@ module Snapdragon
17
17
  return spec_file_objs
18
18
  end
19
19
 
20
- def require_paths
21
- require_paths = Set.new
20
+ def require_files
21
+ return get_require_files_from_files(spec_files)
22
+ end
22
23
 
23
- spec_files.each do |foo|
24
- require_paths.merge(foo.require_paths)
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 require_paths
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
@@ -1,3 +1,3 @@
1
1
  module Snapdragon
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -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.require_paths.each do |path| %>
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
@@ -38,4 +38,8 @@ describe Snapdragon::Suite do
38
38
  pending
39
39
  end
40
40
  end
41
+
42
+ describe "#require_files" do
43
+ it "needs to be tested"
44
+ end
41
45
  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.6
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-20 00:00:00.000000000 Z
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