Skip to content
Browse files

respond_with in an inherited app fixes #71

  • Loading branch information...
1 parent a25d1a8 commit 693deb993b7950ec1af77cf0a0226b59e24cc087 @zzak zzak committed Aug 16, 2013
Showing with 16 additions and 3 deletions.
  1. +1 −3 lib/sinatra/respond_with.rb
  2. +15 −0 spec/respond_with_spec.rb
View
4 lib/sinatra/respond_with.rb
@@ -184,8 +184,6 @@ def template_for(name, exts)
end
end
- attr_accessor :ext_map
-
def remap_extensions
ext_map.clear
Rack::Mime::MIME_TYPES.each { |e,t| ext_map[t] << e[1..-1].to_sym }
@@ -237,7 +235,7 @@ def compile!(verb, path, block, options = {})
ENGINES.default = []
def self.registered(base)
- base.ext_map = Hash.new { |h,k| h[k] = [] }
+ base.set :ext_map, Hash.new { |h,k| h[k] = [] }
base.set :template_engines, ENGINES.dup
base.remap_extensions
base.helpers Helpers
View
15 spec/respond_with_spec.rb
@@ -257,6 +257,21 @@ def object.to_pdf; "hi" end
body.should == "generic!"
end
end
+
+ describe "inherited" do
+ it "registers RespondWith in an inherited app" do
+ app = respond_app do
+ register Sinatra::RespondWith
+
+ get '/a' do
+ respond_with :json
+ end
+ end
+
+ self.app = Sinatra::Base.new(app)
+ req('/a', :json).should_not be_ok
+ end
+ end
end
describe :respond_to do

0 comments on commit 693deb9

Please sign in to comment.
Something went wrong with that request. Please try again.