You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
the bad pattern slightly increases cognitive load that forces me to build actual URLs in my mind.
the bad pattern sometimes discourages Test Driven Development.
In TDD, a test comes first. At this point, I know actual URL but I don't know the named routes because the 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.
You don't have to edit test cases when you edit routes.rb. It automatically follows up.
It could be consistent to use named routes in tests if you use named routes in production code.
classArticlesTest < ApplicationSystemTestCasetest"viewing the index"dovisitarticles_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.
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
The text was updated successfully, but these errors were encountered: