Open ohbarye opened 1 year ago
There's some controversy there in the Rails Testing Rails Applications guide.
class BlogFlowTest < ActionDispatch::IntegrationTest
test "can see the welcome page" do
get "/"
class ArticlesTest < ApplicationSystemTestCase
test "viewing the index" do
visit articles_path
Wondering why is it so.
If you don't write route tests and use URL helpers in system/integration, the mapping is not covered. It is risky to have a green CI after changing routes.
I agree with all the responses. But we all have our own way of solving our problems, right? Yeah, so get on with it.
Also, FYI, if any of our curious readers want to know more about test driven development, please read the blog written my colluagues.
I completely agree with this suggestion. Has there been any progress on it?
Would you like to send a pr to kick start tims, @moznion ?
@pirj Thank you for your suggestion. Why not, I'll work on it.
@pirj Hi, I just sent a pull request to this repo #359, and the actual cop implementation is here (not yet pull-requested): https://github.com/rubocop/rubocop-rails/compare/master...moznion:rubocop-rails:http-url?expand=1
What do you think about them?
Hi. This is a proposal about named routes usage in tests. I'd like to hear what you think.
Proposal
Use string literals instead of named routes or URL helpers in tests.
and so on.
Reason
Integration test (e.g. request specs, system specs) is to mimic user eyes and actions. A user could see "/photos", but not "photos_path". I agree with the following idea.
From a programmer's view,
routes.rb
has not been edited yet. (=I don't care about named routes at that moment).Possible Objection
named routes possibly have merits in some points.
routes.rb
. It automatically follows up.References