jasmine-rails 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -126,3 +126,70 @@ Example for Google Chrome (in Mac OS X):
|
|
126
126
|
open -a "Google Chrome" tmp/jasmine/runner.html --args --allow-file-access-from-files
|
127
127
|
|
128
128
|
Again, it's the opinion of the present author that this shouldn't be necessary in any situation but legacy rescue of an existing test suite. With respect specifically to HTML fixtures, please consider [jasmine-fixture](https://github.com/searls/jasmine-fixture) and [my rationale](http://searls.testdouble.com/posts/2011-12-11-jasmine-fixtures.html) for it.
|
129
|
+
|
130
|
+
### Custom Helpers
|
131
|
+
|
132
|
+
If you need to write a custom spec runner template (for example, using requireJS to load components from your specs), you might benifit from
|
133
|
+
custom helper functions. The controller will attempt to load JasmineRails::SpecHelper if it exists. An example:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
# in lib/jasmine_rails/spec_helper.rb
|
137
|
+
Module JasmineRails
|
138
|
+
Module SpecHelper
|
139
|
+
def custom_fuction
|
140
|
+
"hello world"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
```
|
145
|
+
|
146
|
+
Create a custom layout in app/layouts/jasmine_rails/spec_runner.html.erb and reference your helper
|
147
|
+
```erb
|
148
|
+
<%= custom_function %>
|
149
|
+
```
|
150
|
+
|
151
|
+
If you wanted to do something like this using requirejs-rails https://github.com/jwhitley/requirejs-rails, your helper
|
152
|
+
might look like this
|
153
|
+
```
|
154
|
+
|
155
|
+
# in lib/jasmine_rails_spec_helper.rb
|
156
|
+
Module JasmineRails
|
157
|
+
Module SpecHelper
|
158
|
+
# Gives us access to the require_js_include_tag helper
|
159
|
+
include RequirejsHelper
|
160
|
+
end
|
161
|
+
end
|
162
|
+
```
|
163
|
+
|
164
|
+
Remove any reference to src_files in `spec/javascripts/support/jasmine.yml`, to ensure files aren't loaded prematurely
|
165
|
+
|
166
|
+
Create your custom layout `app/layouts/jasmine_rails/spec_runner.html.erb` like so:
|
167
|
+
```erb
|
168
|
+
|
169
|
+
<!DOCTYPE html>
|
170
|
+
<html>
|
171
|
+
<head>
|
172
|
+
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
173
|
+
<title>Jasmine Specs</title>
|
174
|
+
|
175
|
+
<%= stylesheet_link_tag *jasmine_css_files %>
|
176
|
+
<%= requirejs_include_tag %>
|
177
|
+
<%= javascript_include_tag *jasmine_js_files %>
|
178
|
+
</head>
|
179
|
+
<body>
|
180
|
+
<div id="jasmine_content"></div>
|
181
|
+
<%= yield %>
|
182
|
+
</body>
|
183
|
+
</html>
|
184
|
+
|
185
|
+
```
|
186
|
+
|
187
|
+
Use require with a callback to load your components
|
188
|
+
|
189
|
+
```coffeescript
|
190
|
+
|
191
|
+
describe 'test my module', ->
|
192
|
+
require ['my/module'], (Module) ->
|
193
|
+
it 'does something', ->
|
194
|
+
expect(Module.method).toEqual 'something'
|
195
|
+
```
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-05-
|
14
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: -761195228758755014
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
segments:
|
160
160
|
- 0
|
161
|
-
hash:
|
161
|
+
hash: -761195228758755014
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
164
|
rubygems_version: 1.8.23
|