forked from sinatra/sinatra
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ea6db6d
Showing
2 changed files
with
9 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Sinatra::Application.default_options.merge!( | ||
:env => :test, | ||
:run => false, | ||
:raise_errors => true, | ||
:logging => false | ||
) | ||
|
||
Sinatra.application = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
Sinatra::Application.default_options.merge!( | ||
:env => :test, | ||
:run => false, | ||
:raise_errors => true, | ||
:logging => false | ||
) | ||
|
||
Sinatra.application = nil |
ea6db6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m confused. How does this help you with Cucumber? Do you have an example of how you use Cucumber with this patch?
ea6db6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Blake – sorry for the late reply – I saw this comment just now.
The example is here: http://github.com/aslakhellesoy/cucumber/wikis/sinatra
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?
ea6db6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
Test::Unit.run = false if defined?(Test::Unit)
Spec::run = false if defined?(Spec) && Spec::respond_to?(:run=)
HTH