middleman-jasmine 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OWQxOTAxZmYwNjQ3NzU0MjgyYjg5OTJkZDBiYjM5MjMyMWIxNDZjNg==
5
- data.tar.gz: !binary |-
6
- ODE0MzllMzE1ZmNmYzBkOGM2ZmFhZjdlZjVmODFjNmYzNjNjZDEzYg==
2
+ SHA1:
3
+ metadata.gz: 1158957eb31594548d7dcf52caa92ae8b27d9c95
4
+ data.tar.gz: 9cad60f7307f6d49cd1e1db0770e61c69da18632
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZWYxZWYxYzIyNGY3ODlmMGY0ZGYxNjI4MDQ5MDUyYmM0MjRhOTBmNmQ3Njdh
10
- ZjlkYjJkZDJjMzNkZWZkODJlODVjYmI1ZTc3ZDlkNjFmMjFmODgwODc3ZmZk
11
- NjA3YzE3ZDkzYTE1OTYxZGE2MDdmZjZkMWUyOTIwNDgwYjExZGQ=
12
- data.tar.gz: !binary |-
13
- ZTE3MWY5ZTg0ZTQ0OTNjYzQzYjJhNjcwMjFhNGE1YjAyZTU2NDUxNmJiMDgw
14
- NzBlN2YwOTdmYTdiZTg3YjgyMGZhMzg3Mzc3N2Q1OGY5OTFiNDM0NDRkMWQ5
15
- YTRjNzMzZTAxNzQyMTI3MzdhZTMxYWYxYWJjZTRlNmZmMjNkMWE=
6
+ metadata.gz: eedb260e654bd95fc9eb7d03025b8b9116f46c9f9015db6839f846951de19d7d7219a2c6139d02b516aefcd3bbdad2cad98dcf57064c2905a47894799e2d8fd2
7
+ data.tar.gz: e8d02b2663955e708bfd43df2849c67480519d600e9af538c2ca3f3f40ae3e3125a6ceb14884cb24631f8e96b122297bb7a91a6b4f7524e59389c1a0aa8ecfcf
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p392
1
+ 2.0.0-p195
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.0
2
+ ===
3
+ * Upgrade from Jasmine 1.3 to Jasmine 2.0. [johanlunds]
4
+ * Add Rake-task that runs the tests with PhantomJS. Use `rake middleman_jasmine:ci` [johanlunds, mrship]
5
+ * Update to new Middleman extension format [mrship]
6
+
1
7
  0.4.0
2
8
  ===
3
9
  * Add debug_assets option to expand the assets into individual files. Defaults to false.
@@ -35,4 +41,4 @@ Yanked
35
41
  0.0.1
36
42
  ===
37
43
 
38
- * Initial support for Jasmime
44
+ * Initial support for Jasmime
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Middleman::Jasmine
2
2
 
3
- This gem adds the Jasmine runner into a middleman app under the /jasmine path.
4
- It has (optional) support for sprockets.
3
+ This gem adds the Jasmine runner into a middleman app under the `/jasmine` path.
4
+ It has (optional) support for Sprockets.
5
+
6
+ It uses Jasmine 2.0. For Jasmine 1.3 support use the [jasmine_1_3](https://github.com/mrship/middleman-jasmine/tree/jasmine_1_3) branch.
5
7
 
6
8
  ## Installation
7
9
 
@@ -17,22 +19,60 @@ And then execute:
17
19
 
18
20
  First run `bundle exec jasmine init` to setup Jasmine.
19
21
 
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.
22
+ 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.
23
+
21
24
  ```
22
25
  //= require application
23
26
  //= require_tree .
24
27
  ```
25
28
 
26
29
  Add the following code to your `config.rb` file:
30
+
31
+ ```ruby
32
+ activate :jasmine
33
+ ```
34
+
35
+ Write a spec file under `spec/javascripts/` and hit `/jasmine` under your Middleman app, e.g. `http://localhost:4567/jasmine`.
36
+
37
+ You should see the results of the spec pass/fail under Jasmine.
38
+
39
+
40
+ ## Rake
41
+ You can also run the Jasmine-tests using PhantomJS with Rake:
42
+
43
+ Add the following to the `Rakefile` generated from `bundle exec jasmine init`:
44
+
45
+ ```ruby
46
+ require 'middleman'
47
+ require 'middleman-jasmine'
48
+ require 'middleman/jasmine/tasks'
49
+ ```
50
+
51
+ Then use:
52
+
53
+ ```
54
+ rake middleman_jasmine:ci
27
55
  ```
28
- activate :jasmine
56
+
57
+ ## Configuration
58
+
59
+ To configure the extension, use:
60
+
61
+ ```ruby
62
+ activate :jasmine do |options|
63
+ options.fixtures_dir = "spec/javascripts/fixtures"
64
+ options.jasmine_url = "/jasmine"
65
+ options.config_file = "spec/config.yml"
66
+ options.debug_assets = false
67
+ end
29
68
  ```
30
69
 
31
- Write a spec file under spec/javascripts and hit /jasmine under your Middleman app, e.g. http://localhost:4567/jasmine.
70
+ NOTE: `debug_assets` can be used to extract any assets included in the spec files and serve them with `?body=t` to avoid Sprockets compiling them every time a spec re-runs.
71
+
72
+ ## Caveats
32
73
 
33
- You should see the results of the spec pass/fail under Jasmine.
74
+ 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.:
34
75
 
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
76
  ```ruby
37
77
  after_configuration do
38
78
  handlebars_path = File.expand_path('../', ::Handlebars::Source.bundled_path)
@@ -43,18 +83,6 @@ after_configuration do
43
83
  end
44
84
  ```
45
85
 
46
- To configure the extension, use:
47
- ```
48
- activate :jasmine do |options|
49
- options.fixtures_dir = "spec/javascripts/fixtures"
50
- options.jasmine_url = "/jasmine"
51
- options.config_file = "spec/config.yml"
52
- options.debug_assets = false
53
- end
54
- ```
55
-
56
- NOTE: `debug_assets` can be used to extract any assets included in the spec files and serve them with `?body=t` to avoid sprockets compiling them every time a spec re-runs.
57
-
58
86
  ## Contributing
59
87
 
60
88
  1. Fork it
@@ -1,9 +1,6 @@
1
1
  require "middleman/jasmine/version"
2
- require "middleman/jasmine/extension"
3
2
 
4
3
  ::Middleman::Extensions.register(:jasmine) do
5
- ::Middleman::Jasmine
4
+ require "middleman/jasmine/extension"
5
+ ::Middleman::JasmineExtension
6
6
  end
7
-
8
-
9
-
@@ -2,51 +2,42 @@ require 'middleman-core'
2
2
  require 'middleman/jasmine/jasmine_sprockets_proxy'
3
3
 
4
4
  module Middleman
5
- module Jasmine
6
- class << self
7
- def registered(app, options_hash={}, &block)
8
- app.send :include, InstanceMethods
9
-
10
- options = OpenStruct.new(default_options.merge(options_hash))
11
-
12
- yield options if block_given?
13
-
14
- app.map(options.jasmine_url) { run ::JasmineSprocketsProxy.new }
15
- jasmine_asset_folders.each do |item|
16
- app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
17
- end
18
-
19
- app.map("/#{options.fixtures_dir}") { run Rack::Directory.new(options.fixtures_dir) }
20
-
21
- app.after_configuration do
22
- ::JasmineSprocketsProxy.configure(sprockets, options.config_file, options.debug_assets)
23
- end
5
+ class JasmineExtension < Extension
6
+ option :jasmine_url, "/jasmine"
7
+ option :fixtures_dir, "spec/javascripts/fixtures"
8
+ option :config_file, nil
9
+ option :debug_assets, false
10
+
11
+ attr_reader :jasmine_url
12
+ def initialize(app, options_hash={}, &block)
13
+ super
14
+ _o = options
15
+
16
+ app.map(_o.jasmine_url) { run ::JasmineSprocketsProxy.new }
17
+ jasmine_asset_folders.each do |item|
18
+ app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
24
19
  end
25
20
 
26
- private
21
+ app.map("/#{_o.fixtures_dir}") { run Rack::Directory.new(_o.fixtures_dir) }
27
22
 
28
- def jasmine_asset_folders
29
- [
30
- "__jasmine__", "__boot__", "__spec__"
31
- ]
23
+ app.after_configuration do
24
+ ::JasmineSprocketsProxy.configure(sprockets, _o.config_file, _o.debug_assets)
32
25
  end
33
-
34
- def default_options
35
- {
36
- jasmine_url: "/jasmine",
37
- fixtures_dir: "spec/javascripts/fixtures",
38
- config_file: nil,
39
- debug_assets: false
40
- }
41
- end
42
-
43
- alias :included :registered
26
+ @jasmine_url = _o.jasmine_url
44
27
  end
45
28
 
46
- module InstanceMethods
29
+ helpers do
47
30
  def jasmine_sprockets
48
31
  ::JasmineSprocketsProxy.sprockets_app
49
32
  end
50
33
  end
34
+
35
+ private
36
+
37
+ def jasmine_asset_folders
38
+ [
39
+ "__jasmine__", "__boot__", "__spec__"
40
+ ]
41
+ end
51
42
  end
52
43
  end
@@ -0,0 +1,42 @@
1
+ require 'middleman/rack'
2
+
3
+ require 'json'
4
+ require 'jasmine'
5
+ require 'jasmine/config'
6
+
7
+ namespace :middleman_jasmine do
8
+ desc 'Run Jasmine-tests with PhantomJS and print result. Exit with code 1 or 0.'
9
+
10
+ task :ci do
11
+ config = Jasmine.config
12
+ logger = Logger.new($stdout)
13
+ logger.level = Logger::WARN
14
+ server = Rack::Server.new(:app => Middleman.server, :Port => config.port(:ci), :AccessLog => [], :Logger => logger)
15
+
16
+ t = Thread.new do
17
+ begin
18
+ server.start
19
+ rescue ChildProcess::TimeoutError
20
+ end
21
+ # # ignore bad exits
22
+ end
23
+ t.abort_on_exception = true
24
+ Jasmine::wait_for_listener(config.port(:ci), 'jasmine server')
25
+ puts 'jasmine server started.'
26
+
27
+ formatters = config.formatters.map { |formatter_class| formatter_class.new }
28
+
29
+ exit_code_formatter = Jasmine::Formatters::ExitCode.new
30
+ formatters << exit_code_formatter
31
+
32
+ middleman_extensions = ::Middleman::Application.server.inst.extensions
33
+ throw "Middleman Jasmine extension not activated" unless middleman_extensions.has_key?(:jasmine)
34
+
35
+ path = middleman_extensions[:jasmine].jasmine_url
36
+ url = "#{config.host}:#{config.port(:ci)}#{path}"
37
+ runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url)
38
+ runner.run
39
+
40
+ abort unless exit_code_formatter.succeeded?
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Jasmine
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'jasmine', "~> 1.3"
22
- spec.add_dependency 'middleman-core'
21
+ spec.add_dependency 'jasmine', "~> 2.0.0"
22
+ spec.add_dependency 'middleman', '~> 3.3.2'
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Shipman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jasmine
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: middleman-core
28
+ name: middleman
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.3.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 3.3.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Jasmine testing framework support for Middleman
@@ -84,6 +84,7 @@ files:
84
84
  - lib/middleman-jasmine.rb
85
85
  - lib/middleman/jasmine/extension.rb
86
86
  - lib/middleman/jasmine/jasmine_sprockets_proxy.rb
87
+ - lib/middleman/jasmine/tasks.rb
87
88
  - lib/middleman/jasmine/version.rb
88
89
  - lib/middleman_extension.rb
89
90
  - middleman-jasmine.gemspec
@@ -97,17 +98,17 @@ require_paths:
97
98
  - lib
98
99
  required_ruby_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
- - - ! '>='
101
+ - - '>='
101
102
  - !ruby/object:Gem::Version
102
103
  version: '0'
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
- - - ! '>='
106
+ - - '>='
106
107
  - !ruby/object:Gem::Version
107
108
  version: '0'
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 2.1.11
111
+ rubygems_version: 2.2.2
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Integrates Jasmine into a Middleman app. Optional support for Sprockets.