Skip to content

Commit

Permalink
Implemented Rack::Builder.app and added specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodd committed Sep 13, 2008
1 parent 236bdcc commit f291d06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rack/builder.rb
Expand Up @@ -22,6 +22,10 @@ def initialize(&block)
instance_eval(&block) if block_given?
end

def self.app(&block)
self.new(&block).to_app
end

def use(middleware, *args, &block)
@ins << if block_given?
lambda { |app| middleware.new(app, *args, &block) }
Expand Down
11 changes: 11 additions & 0 deletions test/spec_rack_builder.rb
Expand Up @@ -47,4 +47,15 @@
response.body.to_s.should.equal 'Hi Boss'
end

specify "has explicit #to_app" do
app = Rack::Builder.app do
use Rack::ShowExceptions
run lambda { |env| raise "bzzzt" }
end

Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
end

end

0 comments on commit f291d06

Please sign in to comment.