Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 369 lines (251 sloc) 19.561 kb
e33246a @velesin added documentation
authored
1 # jasmine-jquery
2
3 jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/jasmine/) JavaScript Testing Framework:
4
5 - a set of custom matchers for jQuery framework
6 - an API for handling HTML fixtures in your specs
b28d35f @velesin Updated readme - searching for co-maintainers
authored
7
e33246a @velesin added documentation
authored
8 ## Installation
9
10 Simply download _jasmine-jquery.js_ from the [downloads page](http://github.com/velesin/jasmine-jquery/downloads) and include it in your Jasmine's test runner file (or add it to _jasmine.yml_ file if you're using Ruby with [jasmine-gem](http://github.com/pivotal/jasmine-gem)). Remember to include also jQuery library as jasmine-jquery relies on it.
11
b029cbb @velesin documentation updates
authored
12 For Ruby on Rails I recommend to comply with the standard RSpec and Jasmine frameworks dir structure and keep your tests in `spec/javascripts/` dir. I put jasmine-jquery (and other libraries like jasmine-ajax) into `spec/javascripts/helpers` dir (so they are automatically loaded) and fixtures into `spec/javascripts/fixtures` dir.
13
e33246a @velesin added documentation
authored
14 ## jQuery matchers
15
16 jasmine-jquery provides following custom matchers (in alphabetical order):
17
18 - `toBe(jQuerySelector)`
9b95f78 @gfranko Removed the jQuery size() method calls in favor of the length property t...
gfranko authored
19 - e.g. `expect($('<div id="some-id"></div>')).toBe('div')`
4ff89ba @travisjeffery swap order of lines to be basic to more extensive usage
travisjeffery authored
20 - e.g. `expect($('<div id="some-id"></div>')).toBe('div#some-id')`
e33246a @velesin added documentation
authored
21 - `toBeChecked()`
22 - only for tags that have checked attribute
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
23 - e.g. `expect($('<input type="checkbox" checked="checked"/>')).toBeChecked()`
9b95f78 @gfranko Removed the jQuery size() method calls in favor of the length property t...
gfranko authored
24 - `toBeEmpty()`
14a68a8 @gfranko README formatting
gfranko authored
25 - Checks for child DOM elements or text.
e33246a @velesin added documentation
authored
26 - `toBeHidden()`
250a253 @gfranko README formatting
gfranko authored
27
28 Elements can be considered hidden for several reasons:
14a68a8 @gfranko README formatting
gfranko authored
29 - They have a CSS `display` value of `none`.
30 - They are form elements with `type` equal to `hidden`.
250a253 @gfranko README formatting
gfranko authored
31 - Their `width` and `height` are explicitly set to `0`.
14a68a8 @gfranko README formatting
gfranko authored
32 - An ancestor element is hidden, so the element is not shown on the page.
f1f059f @travisjeffery adds toHaveCss (fixes #68)
travisjeffery authored
33 - `toHaveCss(css)`
34 - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"})`
35 - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"})`
e33246a @velesin added documentation
authored
36 - `toBeSelected()`
37 - only for tags that have selected attribute
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
38 - e.g. `expect($('<option selected="selected"></option>')).toBeSelected()`
e33246a @velesin added documentation
authored
39 - `toBeVisible()`
14a68a8 @gfranko README formatting
gfranko authored
40 - Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
e33246a @velesin added documentation
authored
41 - `toContain(jQuerySelector)`
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
42 - e.g. `expect($('<div><span class="some-class"></span></div>')).toContain('span.some-class')`
e33246a @velesin added documentation
authored
43 - `toExist()`
44 - `toHaveAttr(attributeName, attributeValue)`
45 - attribute value is optional, if omitted it will check only if attribute exists
19a2696 @marcrohloff Added toHaveProp matcher to match 'prop' function in jQuery 1.6
marcrohloff authored
46 - `toHaveProp(propertyName, propertyValue)`
47 - property value is optional, if omitted it will check only if property exists
208051e adding event spies
James A. Rosen authored
48 - `toHaveBeenTriggeredOn(selector)`
49 - if event has been triggered on `selector` (see "Event Spies", below)
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
50 - `toHaveBeenTriggered()`
51 - if event has been triggered on `selector` (see "Event Spies", below)
83c8874 @jandudulski Added new matcher to spyOnEvent: toHaveBeenPreventedOn
jandudulski authored
52 - `toHaveBeenPreventedOn(selector)`
53 - if event has been prevented on `selector` (see "Event Spies", below)
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
54 - `toHaveBeenPrevented()`
55 - if event has been prevented on `selector` (see "Event Spies", below)
e33246a @velesin added documentation
authored
56 - `toHaveClass(className)`
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
57 - e.g. `expect($('<div class="some-class"></div>')).toHaveClass("some-class")`
e33246a @velesin added documentation
authored
58 - `toHaveData(key, value)`
59 - value is optional, if omitted it will check only if an entry for that key exists
60 - `toHaveHtml(string)`
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
61 - e.g. `expect($('<div><span></span></div>')).toHaveHtml('<span></span>')`
05edc48 @travisjeffery add toContainHtml (fixes #76)
travisjeffery authored
62 - `toContainHtml(string)`
63 - e.g. `expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')`
e33246a @velesin added documentation
authored
64 - `toHaveId(id)`
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
65 - e.g. `expect($('<div id="some-id"></div>')).toHaveId("some-id")`
e33246a @velesin added documentation
authored
66 - `toHaveText(string)`
5464336 Matchers: toHaveText now accepts a regex
James A. Rosen authored
67 - accepts a String or regular expression
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
68 - e.g. `expect($('<div>some text</div>')).toHaveText('some text')`
e33246a @velesin added documentation
authored
69 - `toHaveValue(value)`
70 - only for tags that have value attribute
965801e @richardiux Examples should use jquery selectors not html string
richardiux authored
71 - e.g. `expect($('<input type="text" value="some text"/>')).toHaveValue('some text')`
23d2eb2 @evizitei don't forget to use back-ticks
evizitei authored
72 - `toBeDisabled()`
d686286 @wbotelhos Fixed the examples without highlight sintaxe.
wbotelhos authored
73 - e.g. `expect('<input type='submit' disabled='disabled'/>').toBeDisabled()`
7740038 @wbotelhos Added matcher toBeFocused(element) to README.
wbotelhos authored
74 - `toBeFocused()`
d686286 @wbotelhos Fixed the examples without highlight sintaxe.
wbotelhos authored
75 - e.g. `expect($('<input type='text' />').focus()).toBeFocused()`
535c63a @bsingr added toHandle(eventName) and toHandleWith(eventName, eventHandler) to R...
bsingr authored
76 - `toHandle(eventName)`
d686286 @wbotelhos Fixed the examples without highlight sintaxe.
wbotelhos authored
77 - e.g. `expect($form).toHandle("submit")`
535c63a @bsingr added toHandle(eventName) and toHandleWith(eventName, eventHandler) to R...
bsingr authored
78 - `toHandleWith(eventName, eventHandler)`
deb4f29 @travisjeffery fix usage example
travisjeffery authored
79 - e.g. `expect($form).toHandleWith("submit", yourSubmitCallback)`
535c63a @bsingr added toHandle(eventName) and toHandleWith(eventName, eventHandler) to R...
bsingr authored
80
e33246a @velesin added documentation
authored
81 The same as with standard Jasmine matchers, all of above custom matchers may be inverted by using `.not` prefix, e.g.:
82
5464336 Matchers: toHaveText now accepts a regex
James A. Rosen authored
83 expect($('<div>some text</div>')).not.toHaveText(/other/)
e33246a @velesin added documentation
authored
84
55e80b7 @travisjeffery fix readme
travisjeffery authored
85 ## HTML Fixtures
e33246a @velesin added documentation
authored
86
55e80b7 @travisjeffery fix readme
travisjeffery authored
87 The Fixture module of jasmine-jquery allows you to load HTML content to be used by your tests. The overall workflow is like follows:
e33246a @velesin added documentation
authored
88
89 In _myfixture.html_ file:
b029cbb @velesin documentation updates
authored
90
e33246a @velesin added documentation
authored
91 <div id="my-fixture">some complex content here</div>
92
93 Inside your test:
b029cbb @velesin documentation updates
authored
94
54caf5d @richardiux updating readme, there is no method called loadFixture, using loadFixtur...
richardiux authored
95 loadFixtures('myfixture.html');
e33246a @velesin added documentation
authored
96 $('#my-fixture').myTestedPlugin();
97 expect($('#my-fixture')).to...;
98
ec6365e @jorgemanrubia Updated README with information on the fixtures path
jorgemanrubia authored
99 By default, fixtures are loaded from `spec/javascripts/fixtures`. You can configure this path: `jasmine.getFixtures().fixturesPath = 'my/new/path';`.
100
e33246a @velesin added documentation
authored
101 Your fixture is being loaded into `<div id="jasmine-fixtures"></div>` container that is automatically added to the DOM by the Fixture module (If you _REALLY_ must change id of this container, try: `jasmine.getFixtures().containerId = 'my-new-id';` in your test runner). To make tests fully independent, fixtures container is automatically cleaned-up between tests, so you don't have to worry about left-overs from fixtures loaded in preceeding test. Also, fixtures are internally cached by the Fixture module, so you can load the same fixture file in several tests without penalty to your test suite's speed.
102
103 To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it:
104
105 jasmine.getFixtures().load(...);
106
107 There are also global short cut functions available for the most used methods, so the above example can be rewritten to just:
108
109 loadFixtures(...);
110
111 Several methods for loading fixtures are provided:
112
113 - `load(fixtureUrl[, fixtureUrl, ...])`
114 - Loads fixture(s) from one or more files and automatically appends them to the DOM (to the fixtures container).
fce10f2 @fojas replaced add boolean in set and load with appendSet and appendLoad funct...
fojas authored
115 - `appendLoad(fixtureUrl[, fixtureUrl, ...])`
116 - Same as load, but adds the fixtures to the pre-existing fixture container.
e33246a @velesin added documentation
authored
117 - `read(fixtureUrl[, fixtureUrl, ...])`
118 - Loads fixture(s) from one or more files but instead of appending them to the DOM returns them as a string (useful if you want to process fixture's content directly in your test).
119 - `set(html)`
120 - Doesn't load fixture from file, but instead gets it directly as a parameter (html parameter may be a string or a jQuery element, so both `set('<div></div>')` and `set($('<div/>'))` will work). Automatically appends fixture to the DOM (to the fixtures container). It is useful if your fixture is too simple to keep it in an external file or is constructed procedurally, but you still want Fixture module to automatically handle DOM insertion and clean-up between tests for you.
ea9ba3c @samcrang Fix markdown.
samcrang authored
121 - `appendSet(html)`
fce10f2 @fojas replaced add boolean in set and load with appendSet and appendLoad funct...
fojas authored
122 - Same as set, but adds the fixtures to the pre-existing fixture container.
b029cbb @velesin documentation updates
authored
123 - `preload(fixtureUrl[, fixtureUrl, ...])`
124 - Pre-loads fixture(s) from one or more files and stores them into cache, without returning them or appending them to the DOM. All subsequent calls to `load` or `read` methods will then get fixtures content from cache, without making any AJAX calls (unless cache is manually purged by using `clearCache` method). Pre-loading all fixtures before a test suite is run may be useful when working with libraries like jasmine-ajax that block or otherwise modify the inner workings of JS or jQuery AJAX calls.
e33246a @velesin added documentation
authored
125
126 All of above methods have matching global short cuts:
127
128 - `loadFixtures(fixtureUrl[, fixtureUrl, ...])`
fce10f2 @fojas replaced add boolean in set and load with appendSet and appendLoad funct...
fojas authored
129 - `appendLoadFixtures(fixtureUrl[, fixtureUrl, ...])`
e33246a @velesin added documentation
authored
130 - `readFixtures(fixtureUrl[, fixtureUrl, ...])`
131 - `setFixtures(html)`
fce10f2 @fojas replaced add boolean in set and load with appendSet and appendLoad funct...
fojas authored
132 - `appendSetFixtures(html)`
7c8efc5 @fojas added ability to add fixtures to pre-existing fixtures
fojas authored
133
e33246a @velesin added documentation
authored
134 Also, a helper method for creating HTML elements for your tests is provided:
135
136 - `sandbox([{attributeName: value[, attributeName: value, ...]}])`
137
138 It creates an empty DIV element with a default id="sandbox". If a hash of attributes is provided, they will be set for this DIV tag. If a hash of attributes contains id attribute it will override the default value. Custom attributes can also be set. So e.g.:
139
140 sandbox();
141
142 Will return:
143
144 <div id="sandbox"></div>
145
146 And:
147
148 sandbox({
149 id: 'my-id',
150 class: 'my-class',
151 myattr: 'my-attr'
152 });
153
154 Will return:
155
156 <div id="my-id" class="my-class" myattr="my-attr"></div>
157
158 Sandbox method is useful if you want to quickly create simple fixtures in your tests without polluting them with HTML strings:
159
160 setFixtures(sandbox({class: 'my-class'}));
161 $('#sandbox').myTestedClassRemoverPlugin();
162 expect($('#sandbox')).not.toHaveClass('my-class');
163
164 This method also has a global short cut available:
165
166 - `sandbox([{attributeName: value[, attributeName: value, ...]}])`
167
168 Additionally, two clean up methods are provided:
169
170 - `clearCache()`
171 - purges Fixture module internal cache (you should need it only in very special cases; typically, if you need to use it, it may indicate a smell in your test code)
172 - `cleanUp()`
173 - cleans-up fixtures container (this is done automatically between tests by Fixtures module, so there is no need to ever invoke this manually, unless you're testing a really fancy special case and need to clean-up fixtures in the middle of your test)
174
175 These two methods do not have global short cut functions.
176
369487f @angryobject Allow loading style fixtures (fix #87)
angryobject authored
177 ## Style Fixtures
178
55e80b7 @travisjeffery fix readme
travisjeffery authored
179 The StyleFixtures module is pretty much like the Fixtures module, but it allows you to load CSS content on the page while testing. It may be useful if your tests expect that certain css rules are applied to elements that you are testing. The overall workflow is typically the same:
369487f @angryobject Allow loading style fixtures (fix #87)
angryobject authored
180
181 In _mycssfixture.css_ file:
182
183 .elem { position: absolute }
184
185 Inside your test:
186
93f8184 @travisjeffery fix style (#91)
travisjeffery authored
187 loadStyleFixtures('mycssfixture.css');
369487f @angryobject Allow loading style fixtures (fix #87)
angryobject authored
188 $('#my-fixture').myTestedPlugin();
189 expect($('#my-fixture .elem')).toHaveCss({left: "300px"});
190
191 Notice that if you haven't applied the `position: absolute` rule to the `.elem` and try to test its left position in some browsers (e.g. GoogleChrome) you will allways get the value `auto` even if your plugin did everything correct and applied positioning. So that's why you might need to load style fixtures. In Firefox though you will get the correct value even without the `position: absolute`.
192
193 By default, style fixtures are loaded from `spec/javascripts/fixtures`. You can configure this path: `jasmine.getStyleFixtures().fixturesPath = 'my/new/path';`.
194
195 Like in Fixtures module, StyleFixtures are also automatically cleaned-up between tests and are internally cached, so you can load the same fixture file in several tests without penalty to your test suite's speed.
196
197 To invoke fixture related methods, obtain StyleFixtures singleton through a factory and invoke a method on it:
198
199 jasmine.getStyleFixtures().load(...);
200
201 There are also global short cut functions available for the most used methods, so the above example can be rewritten to just:
202
203 loadStyleFixtures(...);
204
205 Several methods for loading fixtures are provided:
206
207 - `load(fixtureUrl[, fixtureUrl, ...])`
208 - Loads fixture(s) from one or more files and automatically appends them to the DOM into the HEAD element. This method will remove all existing fixtures loaded previously, if any.
209 - `appendLoad(fixtureUrl[, fixtureUrl, ...])`
210 - Same as load, but it won't remove fixtures you added earlier.
211 - `set(css)`
212 - Doesn't load fixture from file, but instead gets it directly as a parameter (e.g. `set('body {background: red}')`). Automatically appends style to the DOM. It is useful if your css fixture is too simple to keep it in an external file. This method will remove all existing fixtures loaded previously, if any.
213 - `appendSet(css)`
214 - Same as set, but it won't remove fixtures you added earlier.
215 - `preload(fixtureUrl[, fixtureUrl, ...])`
216 - Pre-loads fixture(s) from one or more files and stores them into cache, without returning them or appending them to the DOM. All subsequent calls to `load` methods will then get fixtures content from cache, without making any AJAX calls (unless cache is manually purged by using `clearCache` method).
217
218 All of above methods have matching global short cuts:
219
220 - `loadStyleFixtures(fixtureUrl[, fixtureUrl, ...])`
221 - `appendLoadStyleFixtures(fixtureUrl[, fixtureUrl, ...])`
222 - `setStyleFixtures(css)`
223 - `appendSetStyleFixtures(css)`
224
225 Additionally, two clean up methods are provided:
226
227 - `clearCache()`
228 - purges StyleFixture module internal cache (you should need it only in very special cases; typically, if you need to use it, it may indicate a smell in your test code)
229 - `cleanUp()`
230 - cleans-up all existing style fixtures (this is done automatically between tests, so there is no need to ever invoke this manually, unless you're testing a really fancy special case and need to clean-up fixtures in the middle of your test)
231
232 These two methods do not have global short cut functions.
233
55e80b7 @travisjeffery fix readme
travisjeffery authored
234 ## JSON Fixtures
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
235
236 The JSONFixtures modules allows you to load JSON data from file (instead of putting huge blocks of data in the spec files).
237
55e80b7 @travisjeffery fix readme
travisjeffery authored
238 In _myjsonfixture.json_ file:
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
239
240 {"property1":"value1", "array1":[1,2,3]}
241
242 Inside your test:
243
93f8184 @travisjeffery fix style (#91)
travisjeffery authored
244 var data = getJSONFixture('myjsonfixture.json');
245 // or load and get the JSON two-step
246 var fixtures = loadJSONFixtures('myjsonfixture.json');
247 var data = fixtures['myjsonfixture.json'];
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
248
249 expect(myDataManipulator.processData(test_data)).to...)
250
cf52849 @travisjeffery keep JSON capitalization consistent with jQuery (#91)
travisjeffery authored
251 By default, fixtures are loaded from `spec/javascripts/fixtures/json`. You can configure this path: `jasmine.getJSONFixtures().fixturesPath = 'my/new/path';`.
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
252
253 Your fixture data is loaded into an object stashed by the JSONFixtures structure. You fetch the data using the filename as the key. This allows you to load multiple chunks of test data in a spec.
254
cf52849 @travisjeffery keep JSON capitalization consistent with jQuery (#91)
travisjeffery authored
255 Because a deep copy of Javascript objects can be a little tricky, this module will refetch data each time you call `load`. If you modify the data within a spec, you must call `load` or `loadJSONFixtures` again to repopulate the data.
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
256
257 To invoke fixture related methods, obtain Fixtures singleton through a factory and invoke a method on it:
258
259 jasmine.getJSONFixtures().load(...);
260
261 There are also global short cut functions available for the most used methods, so the above example can be rewritten to just:
262
cf52849 @travisjeffery keep JSON capitalization consistent with jQuery (#91)
travisjeffery authored
263 loadJSONFixtures(...);
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
264
265 Several methods for loading fixtures are provided:
266
267 - `load(fixtureUrl[, fixtureUrl, ...])`
268 - Loads fixture(s) from one or more files and automatically adds them to the fixture list. This method returns the entire set of fixtures keyed by their filename.
269
270 All of above methods have matching global short cuts:
271
cf52849 @travisjeffery keep JSON capitalization consistent with jQuery (#91)
travisjeffery authored
272 - `loadJSONFixtures(fixtureUrl[, fixtureUrl, ...])`
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
273
cf52849 @travisjeffery keep JSON capitalization consistent with jQuery (#91)
travisjeffery authored
274 - `getJSONFixture(fixtureUrl)`
5fac6a1 @bunnymatic add fixtures module for loading json (close #91)
bunnymatic authored
275 - After you've loaded fixture files, this global helper will retrieve the fixture data given the fixtureUrl
276
277
208051e adding event spies
James A. Rosen authored
278 ## Event Spies
279
280 Spying on jQuery events can be done with `spyOnEvent` and
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
281 `expect(eventName).toHaveBeenTriggeredOn(selector)` or
282 `expect(spyEvent).toHaveBeenTriggered()` . First, spy on the event:
283
284 var spyEvent = spyOnEvent('#some_element', 'click');
285 $('#some_element').click();
286 expect('click').toHaveBeenTriggeredOn('#some_element');
287 expect(spyEvent).toHaveBeenTriggered();
288
289 You can reset spy events
208051e adding event spies
James A. Rosen authored
290
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
291 var spyEvent = spyOnEvent('#some_element', 'click');
208051e adding event spies
James A. Rosen authored
292 $('#some_element').click();
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
293 expect('click').toHaveBeenTriggeredOn('#some_element');
294 expect(spyEvent).toHaveBeenTriggered();
295 // reset spy events
296 spyEvent.reset();
297 expect('click').not.toHaveBeenTriggeredOn('#some_element');
298 expect(spyEvent).not.toHaveBeenTriggered();
208051e adding event spies
James A. Rosen authored
299
83c8874 @jandudulski Added new matcher to spyOnEvent: toHaveBeenPreventedOn
jandudulski authored
300 You can similarly check if triggered event was prevented:
301
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
302 var spyEvent = spyOnEvent('#some_element', 'click');
303 $('#some_element').click(function(event){event.preventDefault();});
83c8874 @jandudulski Added new matcher to spyOnEvent: toHaveBeenPreventedOn
jandudulski authored
304 $('#some_element').click();
ad9d343 @yoshi6jp allow toHaveBeenTriggeredOn to be called with no selector, and toHaveBee...
yoshi6jp authored
305 expect('click').toHaveBeenPreventedOn('#some_element');
306 expect(spyEvent).toHaveBeenPrevented();
83c8874 @jandudulski Added new matcher to spyOnEvent: toHaveBeenPreventedOn
jandudulski authored
307
208051e adding event spies
James A. Rosen authored
308 Much thanks to Luiz Fernando Ribeiro for his
309 [article on Jasmine event spies](http://luizfar.wordpress.com/2011/01/10/testing-events-on-jquery-objects-with-jasmine/).
310
b029cbb @velesin documentation updates
authored
311 ## Dependencies
312
67ae869 @travisjeffery update lib and browser versions
travisjeffery authored
313 jasmine-jquery was tested with Jasmine 1.2 and jQuery 1.8 on IE, FF, Chrome, and Safari. There is a high chance it will work with older versions and other browsers as well, but I don't typically run test suite against them when adding new features.
b029cbb @velesin documentation updates
authored
314
315 ## Cross domain policy problems under Chrome
316
317 Newer versions of Chrome don't allow file:// URIs read other file:// URIs. In effect, jasmine-jquery cannot properly load fixtures under some versions of Chrome. An override for this is to run Chrome with a switch `--allow-file-access-from-files` (I have not verified if this works for all Chrome versions though). The full discussion on this topic can be found in [this GitHub ticket](https://github.com/velesin/jasmine-jquery/issues/4).
318
319 ## Mocking with jasmine-ajax
e33246a @velesin added documentation
authored
320
7ded03c @velesin documentation update
authored
321 [jasmine-ajax](https://github.com/pivotal/jasmine-ajax) library doesn't let user to manually start / stop XMLHttpRequest mocking, but instead it overrides XMLHttpRequest automatically when loaded. This breaks jasmine-jquery fixtures as fixture loading mechanism uses jQuery.ajax, that stops to function the very moment jasmine-ajax is loaded. A workaround for this may be to invoke jasmine-jquery `preloadFixtures` function (specifying all required fixtures) before jasmine-ajax is loaded. This way subsequent calls to `loadFixtures` or `readFixtures` methods will get fixtures content from cache, without need to use jQuery.ajax and thus will work correctly even after jasmine-ajax is loaded.
e33246a @velesin added documentation
authored
322
f397dbe @schickm added not a bottom of readme with hint for using jasmine-jquery with jst...
schickm authored
323 ## Testing with Javascript Test Driver
324
325 When using [jstd](http://code.google.com/p/js-test-driver/) and the jasmine adapter you will need to include jasmine-jquery.js after your jasmine-jstd-adapter files, otherwise jasmine-jquery matchers will not be available when tests are executed.
326
aaef279 @travisjeffery update maintainers and add note on contributing
travisjeffery authored
327 ## Contributing
328
ee3a7e5 @travisjeffery update dates on license
travisjeffery authored
329 jasmine-jquery is maintained by [Travis Jeffery](http://github.com/travisjeffery).
aaef279 @travisjeffery update maintainers and add note on contributing
travisjeffery authored
330
b9a4d27 @travisjeffery make the contributing guidelines comprehensive
travisjeffery authored
331 ### Setup
aaef279 @travisjeffery update maintainers and add note on contributing
travisjeffery authored
332
b9a4d27 @travisjeffery make the contributing guidelines comprehensive
travisjeffery authored
333 - Fork the project and clone the repository.
334
335 [Here's how.](http://help.github.com/fork-a-repo/)
336 - Create a dedicated branch.
337
338 `git checkout -b your_feature`
339
340 ### Writing the Code
341
342 - Get the code right.
343 - Include tests that fail without your code, and pass with it.
344 - Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
6b4caed @travisjeffery note about npm style in project
travisjeffery authored
345 - Follow the conventions in the source you see used already, basically [npm coding style](http://npmjs.org/doc/coding-style.html)
b9a4d27 @travisjeffery make the contributing guidelines comprehensive
travisjeffery authored
346
347 If you can, have another developer sanity check your change.
348
349 ### Committing
350
351 - Commit your change with a message on what you changed in the commit.
352
353 `git commit -am "A commit message on what you changed"`
354 - Please squash your commits when appropriate. This simplifies future cherry picks, and also keeps the git log clean.
355
356 [Here's how.](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
357 - Push to your remote
358
359 `git push origin your_feature`
360
361 ### Issue a Pull Request
362
363 - Navigate to the jasmine-jquery GitHub page, press "Pull Request".
364 - Write your branch name in the branch field, press "Update Commit Range".
365 - Fill in some details about your potential patch including a meaningful
366 title. When finished, press "Send pull request".
367
368 (These guidelines are heavily inspired and similar to [Rails's](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-code)).
Something went wrong with that request. Please try again.