Permalink
Browse files

when passed a class into app, du not subclass that class but use it a…

…s app instead
  • Loading branch information...
1 parent cbe9a48 commit d9a2132a5c4a5d96e9c5823816304eb881acd60b @rkh committed Feb 27, 2010
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/sinatra/test_helper.rb
View
@@ -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

0 comments on commit d9a2132

Please sign in to comment.