Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
Screw.Unit 0.3

Screw.Unit 0.3 is now available. I’m skipping 0.2 since there have been two milestones worth of additions to the new version of Screw.Unit. New features:

  • test suite functionality
  • afters
  • global befores and afters
  • enhanced error messages
  • new matchers

Here’s how to do a global before:

Screw.Unit(function() {
  before(function() {
    ActiveAjaxRequests.length = 0;
    PainPoint.instances = [];
    delete window._token;

Put this, for instance, in your spec_helper.js file.

Here is how to manage a suite:

Have a suite.html file that requires the Screw.Unit source, your spec helper, and your various test files.

    <script src="../lib/jquery-1.2.3.js"></script>
    <script src="../lib/jquery.fn.js"></script>
    <script src="../lib/jquery.print.js"></script>
    <script src="../lib/screw.builder.js"></script>
    <script src="../lib/screw.matchers.js"></script>
    <script src="../lib/"></script>
    <script src="../lib/screw.behaviors.js"></script>
    <script src="spec_helper.js"></script> <!-- SPEC HELPER -->
    <script src="behaviors_spec.js"></script><!-- A SPEC -->
    <script src="matchers_spec.js"></script> <!-- ANOTHER SPEC -->
    <link rel="stylesheet" href="../lib/screw.css">

Have a test file (for example, matchers_spec.js):

Screw.Unit(function() {
  var global_before_invoked = false;
  before(function() { global_before_invoked = true });

  describe('Behaviors', function() {
    describe('#run', function() {
      describe("a simple [describe]", function() {
        it("invokes the global [before] before an [it]", function() {
          expect(global_before_invoked).to(equal, true);

Extra Powerful Matchers

// hash equality
expect({a: 'b', c: 'd'}).to(equal, {a: 'b', c: 'd'});

// recursive array equality
expect([{a: 'b'}, {c: 'd'}]).to(equal, [{a: 'b'}, {c: 'd'}]);

// regular expressions and string inclusion
expect("The wheels of the bus").to(match, /bus/);
expect("The wheels of the bus").to(match, "wheels");

// array emptiness:

Thanks To

  • Brian Takita for the ideas and much of the implementation.
  • Chad Woolley

    Wow. I wonder where I could get Screw::Unit. Hmm, no link in this article… Guess I have to find it myself.

    Oh, good, I found it on RubyForge at

    Wait a minute. No releases. No Subversion commits either. No indication of where it lives, if not on this RubyForge project. Doesn’t seem like there could be that many projects named “Screw::Unit”…

    OK, I admit, I know where it lives, which is pretty easily find-able via Google, but [I’M JUST SAYIN’]( “You Lack Discipline”)…

    — Chad

  • Brian Takita

    Actually, the RubyForge link is Screw::Unit in a previous life, which is a ruby library. :)

    I think I’ll try to inherit that url for the screw-unit-server.

    Btw, you can get screw-unit from and the screw-unit-server from

  • Chad Woolley

    If is the origin, why goes github show that as being forked from nathansobo/screw-unit? What’s the real origin? If Nathan isn’t maintaining the origin, shouldn’t that be changed? Or am I missing some git subtlety?

  • Jeff Dean

    I can’t get screw-unit to run, and it’s failing with:

    /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:19:in `configuration': uninitialized class variable @@configuration in Rails (NameError)
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:49:in `add_plugin_load_paths'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:46:in `each'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:46:in `add_plugin_load_paths'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:45:in `each'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:45:in `add_plugin_load_paths'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:235:in `add_plugin_load_paths'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `send'
    	from /opt/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `run'
    	from script/screw_unit_server:7

    Have you seen this before? Rails 2.1.0

  • Jeff, I had the same problem. I fixed it by adding the following line to script/screw_unit_server, immediately above the Rails::Initializer line (line 7):

    Rails.configuration =
Share This