-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Use string literals instead of named routes or URL helpers in tests #328
Comments
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. |
This comment was marked as off-topic.
This comment was marked as off-topic.
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. |
…to http method calls For the test cases; to make the actual URL obvious and to facilitate tracking endpoint path changes. Original discussion: rubocop/rails-style-guide#328 Signed-off-by: moznion <[email protected]>
…p method calls Original discussion: rubocop#328 Signed-off-by: moznion <[email protected]>
@pirj What do you think about them? |
…to http method calls For the test cases; to make the actual URL obvious and to facilitate tracking endpoint path changes. Original discussion: rubocop/rails-style-guide#328 Signed-off-by: moznion <[email protected]>
Agreed. I think it would be best to clarify the Rails docs first, then add some guidance here. |
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: