jasmine-rails 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -8
- data/Rakefile +6 -1
- data/app/assets/javascripts/jasmine_rails/application.js +0 -6
- data/app/assets/stylesheets/jasmine_rails/application.css +0 -4
- data/app/views/layouts/jasmine_rails/spec_runner.html.erb +21 -23
- data/config/routes.rb +2 -2
- data/lib/jasmine-rails.rb +1 -0
- data/lib/jasmine_rails/jhw_adapter.rb +56 -0
- data/lib/jasmine_rails/version.rb +1 -1
- data/lib/processes_jasmine_directives.rb +15 -29
- data/lib/tasks/jasmine-rails_tasks.rake +4 -0
- metadata +40 -19
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Next, edit the generated `spec/javascripts/support/jasmine.yml` file to ensure t
|
|
52
52
|
spec_files:
|
53
53
|
- "**/*[Ss]pec.{js,coffee}"
|
54
54
|
|
55
|
-
src_dir:
|
55
|
+
src_dir: app/assets/javascripts
|
56
56
|
|
57
57
|
spec_dir: spec/javascripts
|
58
58
|
|
@@ -106,20 +106,14 @@ If the tests fail, jasmine-headless-webkit will leave its generated spec runner
|
|
106
106
|
|
107
107
|
[Guard](https://github.com/guard/guard) is a great tool for triggering spec runs when files change. To use it, you can bundle these gems:
|
108
108
|
|
109
|
-
group :
|
109
|
+
group :development do
|
110
110
|
...
|
111
|
-
gem 'guard-rails-assets'
|
112
111
|
gem 'guard-jasmine-headless-webkit'
|
113
112
|
...
|
114
113
|
end
|
115
114
|
|
116
115
|
In my Guardfile, this configuration is working well for me:
|
117
116
|
|
118
|
-
guard 'rails-assets' do
|
119
|
-
watch(%r{^.*/assets/.+$})
|
120
|
-
watch('config/application.rb')
|
121
|
-
end
|
122
|
-
|
123
117
|
spec_location = "spec/javascripts/%s_spec"
|
124
118
|
|
125
119
|
guard 'jasmine-headless-webkit' do
|
data/Rakefile
CHANGED
@@ -20,7 +20,12 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
est/dummy/Rakefile", __FILE__)
|
24
29
|
load 'rails/tasks/engine.rake'
|
25
30
|
|
26
31
|
|
@@ -1,7 +1 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
1
|
//= require_jasmine js
|
@@ -1,7 +1,3 @@
|
|
1
1
|
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*
|
6
2
|
*= require_jasmine css
|
7
3
|
*/
|
@@ -1,40 +1,38 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
<html
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
3
|
<head>
|
4
4
|
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
5
|
-
<title>Jasmine
|
5
|
+
<title>Jasmine Specs</title>
|
6
6
|
|
7
7
|
<%= stylesheet_link_tag "jasmine_rails/application" %>
|
8
8
|
<%= javascript_include_tag "jasmine_rails/application" %>
|
9
9
|
|
10
10
|
<!-- executing jasmine's runner -->
|
11
11
|
<script type="text/javascript">
|
12
|
-
var jsApiReporter;
|
13
12
|
(function() {
|
14
|
-
|
13
|
+
var jasmineEnv = jasmine.getEnv();
|
14
|
+
jasmineEnv.updateInterval = 1000;
|
15
15
|
|
16
|
-
|
17
|
-
var trivialReporter = new jasmine.TrivialReporter();
|
16
|
+
var htmlReporter = new jasmine.HtmlReporter();
|
18
17
|
|
19
|
-
|
20
|
-
jasmineEnv.addReporter(trivialReporter);
|
18
|
+
jasmineEnv.addReporter(htmlReporter);
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
jasmineEnv.specFilter = function(spec) {
|
21
|
+
return htmlReporter.specFilter(spec);
|
22
|
+
};
|
25
23
|
|
26
|
-
|
24
|
+
var currentWindowOnload = window.onload;
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
execJasmine();
|
33
|
-
};
|
34
|
-
|
35
|
-
function execJasmine() {
|
36
|
-
jasmineEnv.execute();
|
26
|
+
window.onload = function() {
|
27
|
+
if (currentWindowOnload) {
|
28
|
+
currentWindowOnload();
|
37
29
|
}
|
30
|
+
execJasmine();
|
31
|
+
};
|
32
|
+
|
33
|
+
function execJasmine() {
|
34
|
+
jasmineEnv.execute();
|
35
|
+
}
|
38
36
|
|
39
37
|
})();
|
40
38
|
</script>
|
@@ -42,5 +40,5 @@
|
|
42
40
|
<body>
|
43
41
|
<div id="jasmine_content"></div>
|
44
42
|
<%= yield %>
|
45
|
-
|
43
|
+
</body>
|
46
44
|
</html>
|
data/config/routes.rb
CHANGED
data/lib/jasmine-rails.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'jasmine-headless-webkit'
|
2
|
+
|
3
|
+
module JasmineRails
|
4
|
+
|
5
|
+
class JhwAdapter
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@options = Jasmine::Headless::Options.new
|
9
|
+
@runner = Jasmine::Headless::Runner.new(@options)
|
10
|
+
Jasmine::Headless::CacheableAction.enabled = @options[:enable_cache]
|
11
|
+
end
|
12
|
+
|
13
|
+
def css_files
|
14
|
+
@css_files_list ||= CssFilesList.new(
|
15
|
+
:config => @runner.jasmine_config,
|
16
|
+
:only => @options[:files],
|
17
|
+
:seed => @options[:seed]
|
18
|
+
).files
|
19
|
+
end
|
20
|
+
|
21
|
+
def js_files
|
22
|
+
@js_files_list ||= JsFilesList.new(
|
23
|
+
:config => @runner.jasmine_config,
|
24
|
+
:only => @options[:files],
|
25
|
+
:seed => @options[:seed]
|
26
|
+
).files
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
class JsFilesList < Jasmine::Headless::FilesList
|
32
|
+
|
33
|
+
def self.default_files
|
34
|
+
%w{jasmine.js jasmine-html}
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.extension_filter
|
38
|
+
extensions = (%w{.js} + Sprockets.engine_extensions)
|
39
|
+
%r{(#{extensions.join('|')})$}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
class CssFilesList < Jasmine::Headless::FilesList
|
45
|
+
|
46
|
+
def self.default_files
|
47
|
+
%w{jasmine.css}
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.extension_filter
|
51
|
+
extensions = (%w{.css .scss .sass .less})
|
52
|
+
%r{(#{extensions.join('|')})$}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -2,37 +2,23 @@ require 'jasmine-core'
|
|
2
2
|
require 'sprockets/directive_processor'
|
3
3
|
|
4
4
|
class ProcessesJasmineDirectives < Sprockets::DirectiveProcessor
|
5
|
-
ASSET_TYPES = ["css","js"]
|
6
|
-
|
7
5
|
def process_require_jasmine_directive(asset_type)
|
8
|
-
|
9
|
-
|
10
|
-
send("
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
ASSET_TYPES.each do |asset_type|
|
15
|
-
define_method "require_jasmine_#{asset_type}" do
|
16
|
-
Jasmine::Core.send("#{asset_type}_files").each do |f|
|
17
|
-
context.require_asset "/#{Jasmine::Core.path}/#{f}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
define_method "require_user_#{asset_type}" do
|
22
|
-
config = Jasmine::Config.new
|
23
|
-
config.send("#{asset_type}_files").each do |f|
|
24
|
-
context.require_asset full_path_for(f,config)
|
25
|
-
end
|
6
|
+
reset_circular_dependencies
|
7
|
+
context.depend_on(Rails.root)
|
8
|
+
JasmineRails::JhwAdapter.new.send("#{asset_type}_files").each do |full_path|
|
9
|
+
context.depend_on(full_path)
|
10
|
+
context.require_asset(full_path)
|
26
11
|
end
|
27
12
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def reset_circular_dependencies
|
17
|
+
#This is an internal thread-local variable Sprockets uses.
|
18
|
+
# Unfortunately, it's the only way I've found to avoid
|
19
|
+
# (seemingly) spurious `CircularDependencyError`s from being
|
20
|
+
# raised whenever a file changes.
|
21
|
+
Thread.current[:sprockets_circular_calls] = nil
|
37
22
|
end
|
23
|
+
|
38
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasmine-rails
|
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:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
18
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,15 @@ dependencies:
|
|
23
23
|
version: 3.1.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 3.1.0
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
33
|
name: jasmine
|
29
|
-
requirement:
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
30
35
|
none: false
|
31
36
|
requirements:
|
32
37
|
- - ! '>='
|
@@ -34,10 +39,15 @@ dependencies:
|
|
34
39
|
version: '0'
|
35
40
|
type: :runtime
|
36
41
|
prerelease: false
|
37
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
38
48
|
- !ruby/object:Gem::Dependency
|
39
49
|
name: jasmine-headless-webkit
|
40
|
-
requirement:
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
41
51
|
none: false
|
42
52
|
requirements:
|
43
53
|
- - ! '>='
|
@@ -45,10 +55,15 @@ dependencies:
|
|
45
55
|
version: '0'
|
46
56
|
type: :runtime
|
47
57
|
prerelease: false
|
48
|
-
version_requirements:
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
49
64
|
- !ruby/object:Gem::Dependency
|
50
65
|
name: rspec
|
51
|
-
requirement:
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
52
67
|
none: false
|
53
68
|
requirements:
|
54
69
|
- - ! '>='
|
@@ -56,10 +71,15 @@ dependencies:
|
|
56
71
|
version: '0'
|
57
72
|
type: :development
|
58
73
|
prerelease: false
|
59
|
-
version_requirements:
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: gimme
|
62
|
-
requirement:
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
63
83
|
none: false
|
64
84
|
requirements:
|
65
85
|
- - ! '>='
|
@@ -67,7 +87,12 @@ dependencies:
|
|
67
87
|
version: '0'
|
68
88
|
type: :development
|
69
89
|
prerelease: false
|
70
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
71
96
|
description: Provides a Jasmine Spec Runner that plays nicely with Rails 3.1 assets
|
72
97
|
and sets up jasmine-headless-webkit
|
73
98
|
email:
|
@@ -88,8 +113,10 @@ files:
|
|
88
113
|
- config/routes.rb
|
89
114
|
- lib/jasmine-rails.rb
|
90
115
|
- lib/jasmine_rails/engine.rb
|
116
|
+
- lib/jasmine_rails/jhw_adapter.rb
|
91
117
|
- lib/jasmine_rails/version.rb
|
92
118
|
- lib/processes_jasmine_directives.rb
|
119
|
+
- lib/tasks/jasmine-rails_tasks.rake
|
93
120
|
- MIT-LICENSE
|
94
121
|
- Rakefile
|
95
122
|
- README.md
|
@@ -105,21 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
132
|
- - ! '>='
|
106
133
|
- !ruby/object:Gem::Version
|
107
134
|
version: '0'
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
hash: -122910413
|
111
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
136
|
none: false
|
113
137
|
requirements:
|
114
138
|
- - ! '>='
|
115
139
|
- !ruby/object:Gem::Version
|
116
140
|
version: '0'
|
117
|
-
segments:
|
118
|
-
- 0
|
119
|
-
hash: -122910413
|
120
141
|
requirements: []
|
121
142
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.8.
|
143
|
+
rubygems_version: 1.8.24
|
123
144
|
signing_key:
|
124
145
|
specification_version: 3
|
125
146
|
summary: Makes Jasmine easier on Rails 3.1
|