Skip to content
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

"rspec spec/requests/users_spec.rb" test for GET "/me" also tests "sessions#create", which we haven't done yet! #5

Open
brigj1 opened this issue Jul 13, 2022 · 0 comments
Labels
se curriculum Issue for lessons in the Software Engineering program

Comments

@brigj1
Copy link

brigj1 commented Jul 13, 2022

Canvas Link

https://learning.flatironschool.com/courses/5188/assignments/181033?module_item_id=399412

Concern

It took me a long time to figure out what was happening. (And then to write this comment.) It's crunch time now that I'm doing the "putting-it-all-together" lab, and I question the learning value for the time required to understand.

This statement leads the reader to believe that all tests in "spec/requests/users_spec.rb" should pass before moving on:

Make sure the signup and auto-login features work as intended before moving forward. You can test the UsersController requests with RSpec:
 rspec spec/requests/users_spec.rb

Technically, the following error message I get from running "rspec spec/requests/users_spec.rb"

  1. Users GET /me returns the first user when the first user is logged in
    Failure/Error: post "/login", params: { username: user1.username, password: user1.password }

is flagging "/login" as the problem, which is not associated with either "users#create" or "users#show". But that fact is shrouded with the "don't mess with our tests" authority statement from rspec regarding "1) Users GET /me returns the first user when the first user is logged in". That is, as students we are trusting that "UsersController" tests will only be testing stuff in "users_controller.rb", but the test for "GET /me" slips in a test of "/login", a "SessionsController" method routing to "sessions#create" that we have not yet written per:

      post "/login", params: { username: user1.username, password: user1.password }
      get "/me"

We see this second test failing for the same reason:
it "returns the second user when the second user is logged in"

The warning to make things work before moving forward traps the student in a murky place. It wastes precious time until we either give up heeding the warning or else notice that the test for
get "/me", to: "users#show"
is failing because it's also testing
post "/login", to: "sessions#create"

Additional Context

No response

Suggested Changes

It's understandable that we must log in to test whether a session persists. Maybe this combo test can go in a file that advertises that it's testing two different controllers, e.g. "spec/requests/users_sessions_spec.rb"

And then use different wording in the lab regarding how to test GET "/me" before moving on.

Something.

@brigj1 brigj1 added the se curriculum Issue for lessons in the Software Engineering program label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
se curriculum Issue for lessons in the Software Engineering program
Projects
None yet
Development

No branches or pull requests

1 participant