Permalink
Browse files

making Sinon.js optional and improving documentation; fixes #5

  • Loading branch information...
1 parent df239ec commit 84be3e6015bd75ab8e9c82c44a36e56bb3e976a5 Sam Breed committed Oct 15, 2011
View
@@ -10,9 +10,7 @@ write your JS tests in CoffeeScript!
TestTrack is a mountable engine whichs provides routes to
Javascript test runners pre-loaded with your application's code and
-tests. In addition to the test runners, [Sinon.js][sinon] is included
-for mocking, spies, and XHR faking. It's usage is entirely optional and
-won't affect pre-existing test suites.
+tests.
## Usage
@@ -63,6 +61,25 @@ And you're off the the races. An index is provided with links to the test
runners. They would be accessible at `/test/jasmine` and
`/test/qunit` in the example above.
+## Sinon.js
+
+In addition to the test runners, [Sinon.js][sinon] is included by
+default. It's a great set of tooling for mocking, spies, and XHR
+faking. In general, Sinon.js will not affect any pre-existing test
+suites, but there are some gotcha's. Be sure to [check the out the
+documentation][sinon-docs] if you haven't used it before
+
+In Sinon's default settings, _setTimeout and setInterval are
+overwritten_. To change this behavior you need to modify Sinon's config
+object before your tests run.
+
+ sinon.config.useFakeTimers = false;
+
+To not include Sinon, add the following to your TestTrack initiailizer.
+]
+ config.include_sinon = false
+
+
## Production
Obviously, you may not want to have these routes available if your app
@@ -76,6 +93,7 @@ This project uses the MIT-LICENSE.
[jasmine]: https://github.com/pivotal/jasmine
-[qunit]: https://github.com/jquery/qunit
-[sinon]: http://sinonjs.org/
+[qunit]: https://github.com/jquery/qunit
+[sinon]: http://sinonjs.org/
+[sinon-docs]: http://sinonjs.org/docs/
@@ -1,5 +1,3 @@
//= require jasmine/jasmine
//= require jasmine/jasmine-html
-//= require sinon/sinon-1.1.1
-//= require sinon/jasmine-sinon
@@ -1,3 +1 @@
-//= require sinon/sinon-1.1.1
//= require qunit/qunit
-//= require sinon/sinon-qunit-1.0.0
@@ -6,6 +6,11 @@
<%= stylesheet_link_tag "jasmine/jasmine" %>
<%= javascript_include_tag "test_track/jasmine_suite" %>
+ <% if TestTrack.include_sinon %>
+ <%= javascript_include_tag 'sinon/sinon-1.1.1' %>
+ <%= javascript_include_tag 'sinon/jasmine-sinon' %>
+ <% end %>
+
<%= javascript_include_multiple TestTrack.application_manifest %>
<%= javascript_include_tag TestTrack.jasmine_manifest %>
@@ -4,7 +4,17 @@
<meta charset="UTF-8" />
<title>QUnit Test Suite</title>
<%= stylesheet_link_tag 'qunit/qunit' %>
+
+ <% if TestTrack.include_sinon %>
+ <%= javascript_include_tag 'sinon/sinon-1.1.1' %>
+ <% end %>
+
<%= javascript_include_tag 'test_track/qunit_suite' %>
+
+ <% if TestTrack.include_sinon %>
+ <%= javascript_include_tag 'sinon/sinon-qunit-1.0.0' %>
+ <% end %>
+
<%= javascript_include_multiple TestTrack.application_manifest %>
<%= javascript_include_tag TestTrack.qunit_manifest %>
</head>
View
@@ -17,6 +17,9 @@ module TestTrack
mattr_accessor :qunit_path
@@qunit_path = "test/javascripts"
+ mattr_accessor :include_sinon
+ @@include_sinon = true
+
def self.setup
yield self
end
@@ -1,3 +1,4 @@
TestTrack.setup do |config|
config.qunit_manifest = "test/qunit"
+ #config.include_sinon = false
end
@@ -1,3 +1,5 @@
+//sinon.config.useFakeTimers = false;
+
module("TDD JavaScript, Rails 3.1 and the Asset Pipeline");
test("Are you TDD'ing your JS?", function(){
@@ -7,3 +9,11 @@ test("Are you TDD'ing your JS?", function(){
equals( tests, "Lots of tests :D", "How many tests?" );
});
+// Use this to test whether or not Sinon is messing with your timers
+
+//asyncTest("timeout should something something", function(){
+ //setTimeout(function(){
+ //start();
+ //ok(true, "Yay!");
+ //}, 1);
+//});

0 comments on commit 84be3e6

Please sign in to comment.