Skip to content

Commit

Permalink
when passed a class into app, du not subclass that class but use it a…
Browse files Browse the repository at this point in the history
…s app instead
  • Loading branch information
rkh committed Feb 27, 2010
1 parent cbe9a48 commit d9a2132
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/sinatra/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ def app(*options, &block)
else raise ArgumentError, "cannot handle #{option.inspect}"
end
end
superclass = options.shift if options.first.is_a? Class
superclass ||= Sinatra::Base
@app = Class.new(superclass, &block)
inspection = "app"
inspection = "app"
inspection << "(" << options.map { |o| o.inspect }.join(", ") << ")" unless options.empty?
inspection << " { ... }" if block
if options.first.is_a? Class
@app = options.shift
@app.class_eval(&block) if block
else
@app = Class.new(Sinatra::Base, &block)
end
options.each do |option|
if option.is_a? Hash then @app.set option
else @app.register option
Expand Down

0 comments on commit d9a2132

Please sign in to comment.