Permalink
Browse files

Updated README

  • Loading branch information...
1 parent 7f2c39e commit 3710cb27235f6ccf475fef3138fd07fbbb08b3f8 @drogus committed Jul 26, 2009
Showing with 27 additions and 1 deletion.
  1. +27 −1 README.markdown
View
@@ -23,6 +23,32 @@ Additionally Smoke now has a macro for mocking anonymous functions this is great
$.bind('click', callback);
$.trigger('click');
+Ajax mocking (With Screw.Unit)
+-----------------------------
+
+It's as easy as Smoke.Ajax.mock("/giveMeNiceResponseBaby", "Nice Response", 200); which will mock response for given url. In Screw.Unit you need to also use wait() (available in [rsutphin's fork](http://github.com/rsutphin/screw-unit/tree/master)).
+
+Example:
+
+ Screw.Unit(function() {
+ describe("mocking ajax", function() {
+ it("allows mocking ajax request", function() {
+ Smoke.Ajax.mock("/giveMeNiceResponseBaby", "Nice Response", 200);
+ var data, textStatus;
+ $.ajax({
+ url: "/giveMeNiceResponseBaby",
+ success: function(data_, textStatus_) {
+ data = data_;
+ textStatus = textStatus_;
+ }});
+ wait(function() {
+ expect(data).to(equal, "Nice Response");
+ expect(textStatus).to(equal, "success");
+ }, 50);
+ });
+ });
+ });
+
Getting Started (Free Standing)
-------------------------------
Include the library files in your document...
@@ -65,4 +91,4 @@ Known Issues
Contact
-------
-Please send patches, comments or suggestions to andrew.d.kent@gmail.com
+Please send patches, comments or suggestions to andrew.d.kent@gmail.com

0 comments on commit 3710cb2

Please sign in to comment.