Open robyurkowski opened 10 years ago
Strongly second this request; I had the identical problem (wildcard route, momentary confusion about where the tests were). I think we should add a line in the README saying:
"If you have a wildcard route (for instance to handle Ember apps), you should add something like this to your routes.rb
:
mount QUnit::Rails::Engine => 'qunit'
(See also issue #16 for previous discussion.)
I had a bit of an issue this morning when I was trying to get this working. It only took me about 10 minutes to figure out that my wildcard route was swallowing up
/qunit
, but it was still more frustrating than it need have been. I'm on a relatively tight schedule, and if the threshold had been any higher, I might have set this aside for a day when I had more time / not have ever returned to it.So TL;DR: the rationale for this change is 'it eases the installation and use difficulty for a small but non-trivial subset of users.'
So I propose one of two things, and I propose them in order of my own preference:
1) Instead of checking whether a named route for the QUnit controller exists and then mounting it, we should simply use the
qunit:install
generator to insert the mounting line into the host application's route file (and add appropriate documentation to that effect).I think this is the best option, largely because it simplifies the magic, and it would also allow users to customize the URI at which to access the tests. Long-term, this might allow you to provide compatibility with a larger set of codebases than simply Rails (i.e. any Rack app).
Downside: potential breaking change.
2) We should document manual mounting for situations where there is a wildcard route. This is okay, as well, and it would have cut the exploratory time down.
Downside: still more work for wildcard route users, less customizability, README bloating.
Whichever you prefer, I'm happy to do up a PR and handle the legwork. Just figured I'd ask your opinion before getting started.