Created
April 15, 2010 17:25
-
-
Save duien/367381 to your computer and use it in GitHub Desktop.
Get access to the Sinatra application instance that ran the current test in Rack::Test. Created by @bsiggelkow
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
describe LeadService do | |
# Get the Sinatra application instance that ran the current test. For instance you | |
# could use: | |
# | |
# it "should set an instance variable" do | |
# get '/' | |
# app_instance.instance_variable_get(:@lead).should_not be_nil | |
# end | |
# | |
def app_instance | |
ObjectSpace.each_object(LeadService).detect{|o| !o.env.nil?} | |
end | |
# Required for Rack::Test | |
# | |
def app | |
LeadService | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment