Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (37 sloc) 2.008 kb
e9c897a Readme please!
Damien Mathieu authored
1 # MOQUEUR
2
3 ## Presentation
4
5 Moqueur is a jQuery plugin allowing you to mock your ajax requests so they return the value you wish them to.
6 It's particularly useful when testing your javascript code.
7
8 In ruby/rails, with [harmony](http://github.com/mynyml/harmony)/[holygrail](http://github.com/mynyml/holygrail), you can then test your javascript in ruby.
9 For an example, you can check [moqueur's specs](http://github.com/dmathieu/moqueur/blob/master/spec/lib/moqueur_spec.rb).
10
11 ## Installation
12
13 If you only wish to use moqueur, you can just pick the file "moqueur.js" and add it wherever you want in your public directory.
14 In your test environment, add this file in your content. Create some mocks and you're ready to go !
15
16
17 ## Mocking a request
18
19 For now, there's not a lot of options. But more are coming !
20 And if you wish something to be included, feel free to [open a ticket](http://github.com/dmathieu/moqueur/issues).
21
22 You can mock an url with the following :
23
24 jQuery.mockAjax({
25 url: '/test',
26 content: "Hello World !"
27 });
28
29 When whenever you make an ajax request (with jQuery.ajax) to the url /test, no call will really be made and the content returned will be "Hello World".
30
31 Example :
32 jQuery.ajax({url: '/test'});
33
34 You can also use the success method, which will be appropriately executed.
35
36 jQuery.ajax({
37 url: '/test',
38 success: function() {
39 return 'Yay, it works !'
40 }
41 });
42
43 ## Contributing
44
45 If you think Moqueur is great but can be improved, feel free to contribute.
46 To do so, you can :
47
48 * [Fork](http://help.github.com/forking/) the project
49 * Do your changes and commit them to your repository
50 * Test your changes. We won't accept any untested contributions (except if they're not testable).
51 * Create an [issue](http://github.com/dmathieu/moqueur/issues) with a link to your commits.
52
53 And that's it! We'll soon take a look at your issue and review your changes.
54
55 ## Author and Credits
56
57 Damien MATHIEU :: 42 (AT|CHEZ) dmathieu.com
Something went wrong with that request. Please try again.