Browse files

Separate common code from test/unit code to make it easier to use oth…

…er testing tools like Cucumber
  • Loading branch information...
1 parent 55221fc commit ea6db6d4f2bc18777d25702c792ff038fa33b698 @aslakhellesoy committed Oct 13, 2008
Showing with 9 additions and 9 deletions.
  1. +8 −0 lib/sinatra/test/common.rb
  2. +1 −9 lib/sinatra/test/unit.rb
@@ -0,0 +1,8 @@
+ :env => :test,
+ :run => false,
+ :raise_errors => true,
+ :logging => false
+Sinatra.application = nil
@@ -1,13 +1,5 @@
require 'test/unit'
require File.dirname(__FILE__) + '/methods'
+require File.dirname(__FILE__) + '/common'
Test::Unit::TestCase.send(:include, Sinatra::Test::Methods)
- :env => :test,
- :run => false,
- :raise_errors => true,
- :logging => false
-Sinatra.application = nil

3 comments on commit ea6db6d

I’m confused. How does this help you with Cucumber? Do you have an example of how you use Cucumber with this patch?


aslakhellesoy replied Nov 13, 2008

Hi Blake – sorry for the late reply – I saw this comment just now.

The example is here:

It lets me enable the sinatra test environment without having to activate Test::Unit – it interferes with cucumber (setting up exit hooks and what not).

Of course – I could always just copy the lines i factored out, but I prefer to keep things DRY in this case. WDYT?

raggi replied Dec 2, 2008

I don’t know cucumber, but I’d imagine this is related to bad magic.

I could once again beg that everyone stops using at_exit hooks, but you all already know that opinion, and your choices are your own.

I’d recommend just using the following excerpt from my general helper.rb that I use with all bacon projects:

  1. Disable test/unit and rspec from running, in case loaded by broken tools. = false if defined?(Test::Unit)
    Spec::run = false if defined?(Spec) && Spec::respond_to?(:run=)


Please sign in to comment.