register RespondWith is not inherited #71

Closed
jamiehodge opened this Issue Nov 9, 2012 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

jamiehodge commented Nov 9, 2012

require "sinatra/base"
require "sinatra/respond_with"
require "erb"

class Base < Sinatra::Base
  register Sinatra::RespondWith
end

class App < Base

  enable  :inline_templates
  enable  :raise_errors
  disable :show_exceptions

  get "/" do
    respond_with(:home)
  end
end

require "minitest/autorun"
require "rack/test"

class AppTest < MiniTest::Unit::TestCase
  include Rack::Test::Methods

  def app
    App
  end

  def test_respond_with_inheritance
    assert_raises(NoMethodError) { get("/") }
  end
end

__END__
@@home
<h1>hello, world!</h1>
Contributor

jamiehodge commented Jan 25, 2013

I would imagine this is the culprit:

register RespondWith
Delegator.delegate :respond_to

Do we need to add an inherited hook to also delegate :respond_to?

Member

kytrinyx commented Jan 25, 2013

Thanks for the concise example showing the problem, @jamiehodge!

I think you're right. We probably need to add Delegator.delegate :respond_with there.
I'll see if I can figure out how to write the failing test in the style of the project.

Owner

zzak commented Aug 11, 2013

@kytrinyx Any luck?

zzak closed this in 693deb9 Aug 16, 2013

@zzak zzak added a commit that referenced this issue Aug 19, 2013

@zzak zzak add an actual failing test for #71 35df1d2
Contributor

jamiehodge commented Aug 28, 2013

thanks a lot @zzak!

@zzak zzak added a commit to zzak/sinatra-contrib that referenced this issue Jul 22, 2016

@zzak zzak respond_with in an inherited app fixes #71 de29b41

@zzak zzak added a commit to zzak/sinatra-contrib that referenced this issue Jul 22, 2016

@zzak zzak add an actual failing test for #71 875070b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment