Skip to content
jejacks0n edited this page Feb 16, 2014 · 9 revisions

To get setup for QUnit you'll need to configure your suites. Since QUnit tests aren't considered specs, we need to adjust the path to point to test/javascripts. You should make a test/javascripts path and then change your suite(s).

test/teaspoon_env.rb

Teaspoon.configure do |config|
  config.suite do |suite|
    suite.use_framework :qunit    
  end
end

Example Test

//= require jquery
module("My great feature");

test("will change the world", 2, function() {
  ok(true, "Passing is true");
  ok(typeof(jQuery) !== "undefined");
});

Example Fixture Usage

fixture.preload("fixture.html", "fixture.json");

module("Using fixtures", {
  setup: function() {
    fixture.set("<h2>Another Title</h2>");
    this.fixtures = fixture.load("fixture.html", "fixture.json", true);
  }
});

test("loads fixtures", function() {
  ok(document.getElementById("fixture_view").tagName === "DIV", "is in the dom");
  ok(this.fixtures[0] === fixture.el, "has return values for the el");
  ok(this.fixtures[1].title === fixture.json[0].title, "has return values for json");
});