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.
@@ -1,3 +1,10 @@
1
+ 0.1.0
2
+ ===
3
+
4
+ * Configure in #after_configuration block
5
+ * Apply all middleman_sprockets paths to our internal sprockets
6
+ * Expose internal sprockets app with jasmine_sprockets helper
7
+
1
8
  0.0.3
2
9
  ===
3
10
 
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
- //= require_tree .
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 want to include your application.js into the test suite, it is best to do that under jasmine.yml, i.e:
35
- ```yaml
36
- src_files:
37
- - app/javascripts/application.js
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
- @options = OpenStruct.new(default_options.merge(options_hash))
8
+ app.send :include, InstanceMethods
9
9
 
10
- yield @options if block_given?
10
+ options = OpenStruct.new(default_options.merge(options_hash))
11
11
 
12
- app.map(@options.jasmine_url) { run ::JasmineSprocketsProxy.new }
13
- jasmine_asset_folders.each do |item|
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__", @options.fixtures_dir
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
- return @@jasmine_app if defined?(@@jasmine_app)
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
- return @@jasmine_app unless defined?(::Sprockets::Environment)
13
- return @@sprockets_app if defined?(@@sprockets_app)
14
- @@sprockets_app ||= ::Sprockets::Environment.new.tap { |s| s.append_path(Jasmine.config.spec_dir) }
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?
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Jasmine
3
- VERSION = "0.0.3"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
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.3
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-08 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jasmine