Skip to content

Instantly share code, notes, and snippets.

@duien
Created April 15, 2010 17:25
Show Gist options
  • Save duien/367381 to your computer and use it in GitHub Desktop.
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
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