Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

yield the MockRequest to the block before invoking the app [#111]

sr commented this out during some refactoring but I'd like
to leave it in for now.
  • Loading branch information...
commit d4680f721b194fc0fbae7b6910aaf10ec389cfe2 1 parent eba6de6
@rtomayko rtomayko authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  lib/sinatra/test.rb
  2. +9 −0 test/test_test.rb
View
2  lib/sinatra/test.rb
@@ -33,7 +33,7 @@ def make_request(verb, path, data=nil, h=nil)
options[:input] = data
end
- # TODO: yield @request if block_given?
+ yield @request if block_given?
@response = @request.request(verb, path, options)
end
View
9 test/test_test.rb
@@ -101,6 +101,15 @@ def request_params
assert_equal 'text/plain', request['CONTENT_TYPE']
end
+ it 'yields the request object to the block before invoking the application' do
+ called = false
+ get '/' do |req|
+ called = true
+ assert req.kind_of?(Rack::MockRequest)
+ end
+ assert called
+ end
+
def test_TestHarness
session = Sinatra::TestHarness.new(@app)
response = session.get('/')
Please sign in to comment.
Something went wrong with that request. Please try again.