sinatra / sinatra-recipes

Community contributed recipes and techniques
http://recipes.sinatrarb.com/
463 stars 142 forks source link

Minitest Spec should define app within describe block #146

Closed andyvanee closed 5 years ago

andyvanee commented 5 years ago

I'm not sure this is the most common usage pattern, but I am developing a modular application with multiple Apps mounted in config.ru like this:

map('/account') { run AccountController }
# ...
map('/') { run HomeController }

If I use the code suggested, which defines app at the top level and run it with Rake::TestTask, the code will fail and only one app will be loaded (I believe the last one defined).

https://github.com/sinatra/sinatra-recipes/blob/master/testing/minitest.md#specs-and-benchmarks-with-minitest

I've fixed the issue by defining app within the describe block.

describe "home controller" do
  def app
    HomeController
  end
  # ... specs
end

Perhaps the documentation should be adjusted, or at least a note added for testing multiple applications in the same test suite?

Thanks!