middleman-jasmine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/lib/middleman/jasmine.rb +9 -0
- data/lib/middleman/jasmine/extension.rb +32 -0
- data/lib/middleman/jasmine/jasmine_sprockets_proxy.rb +58 -0
- data/lib/middleman/jasmine/version.rb +5 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-jasmine.gemspec +26 -0
- metadata +121 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Andy Shipman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Middleman::Jasmine
|
2
|
+
|
3
|
+
This gem adds the Jasmine runner into a middleman app under the /jasmine path.
|
4
|
+
It has (optional) support for sprockets.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'middleman-jasmine'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
First run `bundle exec jasmine init` to setup Jasmine.
|
19
|
+
|
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
|
+
```
|
22
|
+
//= require_tree .
|
23
|
+
```
|
24
|
+
|
25
|
+
Add the following code to your `config.rb` file:
|
26
|
+
```
|
27
|
+
activate: :jasmine
|
28
|
+
```
|
29
|
+
|
30
|
+
Write a spec file under spec/javascripts and hit /jasmine under your Middleman app, e.g. http://localhost:4567/jasmine.
|
31
|
+
|
32
|
+
You should see the results of the spec pass/fail under Jasmine.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'middleman-core'
|
2
|
+
require 'middleman/jasmine/jasmine_sprockets_proxy'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module Jasmine
|
6
|
+
class << self
|
7
|
+
def registered(app, options_hash={}, &block)
|
8
|
+
options = OpenStruct.new(default_options.merge(options_hash))
|
9
|
+
|
10
|
+
yield options if block_given?
|
11
|
+
|
12
|
+
app.map(options.jasmine_url) { run ::JasmineSprocketsProxy.new }
|
13
|
+
jasmine_asset_folders.each do |item|
|
14
|
+
app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def jasmine_asset_folders
|
21
|
+
%w(__jasmine__ __boot__ __spec__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_options
|
25
|
+
{
|
26
|
+
jasmine_url: "/jasmine"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
alias :included :registered
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'jasmine'
|
2
|
+
|
3
|
+
class JasmineSprocketsProxy
|
4
|
+
class << self
|
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)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
jasmine_app
|
12
|
+
|
13
|
+
def initialize(path="")
|
14
|
+
@path = path
|
15
|
+
@app =
|
16
|
+
if setup_for_spec_files?
|
17
|
+
sprockets_app
|
18
|
+
else
|
19
|
+
self.class.jasmine_app
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def call(env)
|
24
|
+
env["PATH_INFO"] = "/#{@path}#{env["PATH_INFO"]}" unless serving_spec_via_sprockets?
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
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
|
+
def setup_for_spec_files?
|
36
|
+
@path == "__spec__"
|
37
|
+
end
|
38
|
+
|
39
|
+
def serving_spec_via_sprockets?
|
40
|
+
setup_for_spec_files? && !!@sprockets_app && @sprockets_app.is_a?(::Sprockets::Environment)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# monkey patch Rack::Jasmine::Runner to allow for paths other than /
|
45
|
+
module Rack
|
46
|
+
module Jasmine
|
47
|
+
class Runner
|
48
|
+
def call(env)
|
49
|
+
@path = env["PATH_INFO"]
|
50
|
+
[
|
51
|
+
200,
|
52
|
+
{ 'Content-Type' => 'text/html'},
|
53
|
+
[@page.render]
|
54
|
+
]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman/jasmine'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman/jasmine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "middleman-jasmine"
|
8
|
+
spec.version = Middleman::Jasmine::VERSION
|
9
|
+
spec.authors = ["Andy Shipman"]
|
10
|
+
spec.email = ["andy@cllearview.com"]
|
11
|
+
spec.description = %q{Jasmine testing framework support for Middleman}
|
12
|
+
spec.summary = %q{Integrates Jasmine into a Middleman app. Optional support for Sprockets.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'jasmine', "~> 1.3"
|
22
|
+
spec.add_dependency 'middleman-core'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-jasmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andy Shipman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jasmine
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: middleman-core
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Jasmine testing framework support for Middleman
|
79
|
+
email:
|
80
|
+
- andy@cllearview.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- lib/middleman/jasmine.rb
|
91
|
+
- lib/middleman/jasmine/extension.rb
|
92
|
+
- lib/middleman/jasmine/jasmine_sprockets_proxy.rb
|
93
|
+
- lib/middleman/jasmine/version.rb
|
94
|
+
- lib/middleman_extension.rb
|
95
|
+
- middleman-jasmine.gemspec
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.8.24
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Integrates Jasmine into a Middleman app. Optional support for Sprockets.
|
121
|
+
test_files: []
|