Skip to content

Commit

Permalink
yield the MockRequest to the block before invoking the app [sinatra#111]
Browse files Browse the repository at this point in the history
sr commented this out during some refactoring but I'd like
to leave it in for now.
  • Loading branch information
rtomayko committed Feb 24, 2009
1 parent eba6de6 commit d4680f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinatra/test.rb
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions test/test_test.rb
Expand Up @@ -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('/')
Expand Down

0 comments on commit d4680f7

Please sign in to comment.