middleman-jasmine 0.0.1 → 0.0.3

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.
@@ -0,0 +1,15 @@
1
+ 0.0.3
2
+ ===
3
+
4
+ * Only use one Sprockets instance
5
+ * Support for fixtures loading from a :fixtures_dir option
6
+ * Fix for not using Sprockets
7
+
8
+ 0.0.2
9
+ ===
10
+ Yanked
11
+
12
+ 0.0.1
13
+ ===
14
+
15
+ * Initial support for Jasmime
data/README.md CHANGED
@@ -31,6 +31,18 @@ Write a spec file under spec/javascripts and hit /jasmine under your Middleman a
31
31
 
32
32
  You should see the results of the spec pass/fail under Jasmine.
33
33
 
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
38
+ ```
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
+
41
+ To configure the extension, use:
42
+ ```
43
+ activate: :jasmine, fixtures_dir: "spec/javascripts/fixtures", jasmine_url: "/jasmine"
44
+ ```
45
+
34
46
  ## Contributing
35
47
 
36
48
  1. Fork it
@@ -5,11 +5,11 @@ 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
+ @options = OpenStruct.new(default_options.merge(options_hash))
9
9
 
10
- yield options if block_given?
10
+ yield @options if block_given?
11
11
 
12
- app.map(options.jasmine_url) { run ::JasmineSprocketsProxy.new }
12
+ app.map(@options.jasmine_url) { run ::JasmineSprocketsProxy.new }
13
13
  jasmine_asset_folders.each do |item|
14
14
  app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
15
15
  end
@@ -18,12 +18,15 @@ module Middleman
18
18
  private
19
19
 
20
20
  def jasmine_asset_folders
21
- %w(__jasmine__ __boot__ __spec__)
21
+ [
22
+ "__jasmine__", "__boot__", "__spec__", @options.fixtures_dir
23
+ ]
22
24
  end
23
25
 
24
26
  def default_options
25
27
  {
26
- jasmine_url: "/jasmine"
28
+ jasmine_url: "/jasmine",
29
+ fixtures_dir: "spec/javascripts/fixtures"
27
30
  }
28
31
  end
29
32
  alias :included :registered
@@ -7,14 +7,21 @@ class JasmineSprocketsProxy
7
7
  Jasmine.load_configuration_from_yaml
8
8
  @@jasmine_app = Jasmine::Application.app(Jasmine.config)
9
9
  end
10
+
11
+ 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) }
15
+ end
10
16
  end
11
17
  jasmine_app
18
+ sprockets_app
12
19
 
13
20
  def initialize(path="")
14
21
  @path = path
15
22
  @app =
16
23
  if setup_for_spec_files?
17
- sprockets_app
24
+ self.class.sprockets_app
18
25
  else
19
26
  self.class.jasmine_app
20
27
  end
@@ -27,17 +34,12 @@ class JasmineSprocketsProxy
27
34
 
28
35
  private
29
36
 
30
- def sprockets_app
31
- return self.class.jasmine_app unless defined?(::Sprockets::Environment)
32
- @sprockets_app ||= ::Sprockets::Environment.new.tap { |s| s.append_path(Jasmine.config.spec_dir) }
33
- end
34
-
35
37
  def setup_for_spec_files?
36
38
  @path == "__spec__"
37
39
  end
38
40
 
39
41
  def serving_spec_via_sprockets?
40
- setup_for_spec_files? && !!@sprockets_app && @sprockets_app.is_a?(::Sprockets::Environment)
42
+ setup_for_spec_files? && defined?(@@sprockets_app)
41
43
  end
42
44
  end
43
45
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Jasmine
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.3"
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.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -83,6 +83,7 @@ extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
85
  - .gitignore
86
+ - CHANGELOG.md
86
87
  - Gemfile
87
88
  - LICENSE.txt
88
89
  - README.md