middleman-jasmine 0.0.3 → 0.1.0
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.md +7 -0
- data/README.md +11 -6
- data/lib/middleman/jasmine/extension.rb +18 -6
- data/lib/middleman/jasmine/jasmine_sprockets_proxy.rb +19 -9
- data/lib/middleman/jasmine/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,8 @@ First run `bundle exec jasmine init` to setup Jasmine.
|
|
19
19
|
|
20
20
|
Then, if you have sprockets installed through [middleman-sprockets](https://github.com/middleman/middleman-sprockets), you can create a spec.js file in spec/javascripts to include all your specs, i.e.
|
21
21
|
```
|
22
|
-
|
22
|
+
//= require application
|
23
|
+
//= require_tree .
|
23
24
|
```
|
24
25
|
|
25
26
|
Add the following code to your `config.rb` file:
|
@@ -31,12 +32,16 @@ Write a spec file under spec/javascripts and hit /jasmine under your Middleman a
|
|
31
32
|
|
32
33
|
You should see the results of the spec pass/fail under Jasmine.
|
33
34
|
|
34
|
-
If you
|
35
|
-
```
|
36
|
-
|
37
|
-
|
35
|
+
If you add additional paths to sprockets with `append_path` in your `after_configuration` block then you'll most likely need to append the same paths to the Middleman::Jasmine sprockets instance. To do that use the helper `jasmine_sprockets`, i.e.:
|
36
|
+
```ruby
|
37
|
+
after_configuration do
|
38
|
+
handlebars_path = File.expand_path('../', ::Handlebars::Source.bundled_path)
|
39
|
+
sprockets.append_path(handlebars_path)
|
40
|
+
|
41
|
+
# add Handlebars to Jasmine too
|
42
|
+
jasmine_sprockets.append_path(handlebars_path)
|
43
|
+
end
|
38
44
|
```
|
39
|
-
That is because the Sprockets instance that compiles the specs uses spec/javascripts as its path to load the js. This causes issues with loading the application via a `//= require application` line.
|
40
45
|
|
41
46
|
To configure the extension, use:
|
42
47
|
```
|
@@ -5,21 +5,27 @@ module Middleman
|
|
5
5
|
module Jasmine
|
6
6
|
class << self
|
7
7
|
def registered(app, options_hash={}, &block)
|
8
|
-
|
8
|
+
app.send :include, InstanceMethods
|
9
9
|
|
10
|
-
|
10
|
+
options = OpenStruct.new(default_options.merge(options_hash))
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
yield options if block_given?
|
13
|
+
|
14
|
+
app.map(options.jasmine_url) { run ::JasmineSprocketsProxy.new }
|
15
|
+
jasmine_asset_folders(options.fixtures_dir).each do |item|
|
14
16
|
app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
|
15
17
|
end
|
18
|
+
|
19
|
+
app.after_configuration do
|
20
|
+
::JasmineSprocketsProxy.configure(sprockets)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
private
|
19
25
|
|
20
|
-
def jasmine_asset_folders
|
26
|
+
def jasmine_asset_folders(fixtures_dir)
|
21
27
|
[
|
22
|
-
"__jasmine__", "__boot__", "__spec__",
|
28
|
+
"__jasmine__", "__boot__", "__spec__", fixtures_dir
|
23
29
|
]
|
24
30
|
end
|
25
31
|
|
@@ -31,5 +37,11 @@ module Middleman
|
|
31
37
|
end
|
32
38
|
alias :included :registered
|
33
39
|
end
|
40
|
+
|
41
|
+
module InstanceMethods
|
42
|
+
def jasmine_sprockets
|
43
|
+
::JasmineSprocketsProxy.sprockets_app
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
35
47
|
end
|
@@ -3,21 +3,31 @@ require 'jasmine'
|
|
3
3
|
class JasmineSprocketsProxy
|
4
4
|
class << self
|
5
5
|
def jasmine_app
|
6
|
-
|
7
|
-
Jasmine.load_configuration_from_yaml
|
8
|
-
@@jasmine_app = Jasmine::Application.app(Jasmine.config)
|
6
|
+
@@jasmine_app
|
9
7
|
end
|
10
8
|
|
11
9
|
def sprockets_app
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
@@sprockets_app
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(middleman_sprockets)
|
14
|
+
Jasmine.load_configuration_from_yaml
|
15
|
+
@@jasmine_app = Jasmine::Application.app(Jasmine.config)
|
16
|
+
@@sprockets_app =
|
17
|
+
if defined?(::Sprockets::Environment)
|
18
|
+
sprockets = ::Sprockets::Environment.new
|
19
|
+
middleman_sprockets.paths.each do |path|
|
20
|
+
sprockets.append_path(path)
|
21
|
+
end
|
22
|
+
sprockets.append_path(Jasmine.config.spec_dir)
|
23
|
+
sprockets
|
24
|
+
else
|
25
|
+
@@jasmine_app
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
17
|
-
jasmine_app
|
18
|
-
sprockets_app
|
19
29
|
|
20
|
-
def initialize(path="")
|
30
|
+
def initialize(path="", js_dir="")
|
21
31
|
@path = path
|
22
32
|
@app =
|
23
33
|
if setup_for_spec_files?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-jasmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jasmine
|