From ace08b274e115fe26e77597fb34fb209534dab53 Mon Sep 17 00:00:00 2001 From: "Davis W. Frank, dwfrank & Hunter Gillane" Date: Thu, 16 Sep 2010 17:30:06 -0700 Subject: [PATCH] moved frameworks to a separate directory; made a sample spec helper that installs correct Ajax library. Protoype is GREEN --- .../spec/javascripts/support/jasmine.yml | 4 ++-- {lib => frameworks}/jquery.js | 0 {lib => frameworks}/prototype.js | 0 lib/spec-helper.js | 16 ++++++++++++++++ spec/javascripts/support/jasmine.yml | 5 +++-- 5 files changed, 21 insertions(+), 4 deletions(-) rename {lib => frameworks}/jquery.js (100%) rename {lib => frameworks}/prototype.js (100%) create mode 100644 lib/spec-helper.js diff --git a/examples/prototype/spec/javascripts/support/jasmine.yml b/examples/prototype/spec/javascripts/support/jasmine.yml index a4a9e9e..76ca7ff 100644 --- a/examples/prototype/spec/javascripts/support/jasmine.yml +++ b/examples/prototype/spec/javascripts/support/jasmine.yml @@ -11,7 +11,7 @@ # - dist/**/*.js # src_files: - - lib/prototype.js + - frameworks/prototype.js - examples/prototype/public/javascripts/**/*.js # stylesheets @@ -38,8 +38,8 @@ stylesheets: # - helpers/**/*.js # helpers: + - lib/spec-helper.js - examples/prototype/spec/javascripts/helpers/**/*.js - - spec/javascripts/helpers/spec-helper.js # spec_files # diff --git a/lib/jquery.js b/frameworks/jquery.js similarity index 100% rename from lib/jquery.js rename to frameworks/jquery.js diff --git a/lib/prototype.js b/frameworks/prototype.js similarity index 100% rename from lib/prototype.js rename to frameworks/prototype.js diff --git a/lib/spec-helper.js b/lib/spec-helper.js new file mode 100644 index 0000000..d3ed7f3 --- /dev/null +++ b/lib/spec-helper.js @@ -0,0 +1,16 @@ +beforeEach(function() { + + if (typeof jQuery != 'undefined') { + spyOn(jQuery.ajaxSettings, 'xhr').andCallFake(function() { + var newXhr = new FakeXMLHttpRequest(); + ajaxRequests.push(newXhr); + return newXhr; + }); + } else { + spyOn(Ajax, "getTransport").andCallFake(function() { + return new FakeXMLHttpRequest(); + }); + } + clearAjaxRequests(); + +}); diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index f3c5f4b..89dc59c 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -1,8 +1,9 @@ src_dir: . src_files: - - lib/prototype.js - - lib/**/*.js + - frameworks/prototype.js + - frameworks/jquery.js + - lib/mock-ajax.js spec_dir: