Rspec for Pinning App

Hi, all! I am very new to Ruby and working my way through a course and
have
a reached a point where I cannot figure out what I’m doing wrong.

Here is a link to my project on GitHub
https://github.com/michelleisclever/rails-pinning-app. When running
the
/rspec/controllers/users_controller_spec.rb, I receiving the following:
https://github.com/michelleisclever/rails-pinning-app

Pending: (Failures listed here are expected and do not affect your
suite’s
status)

  1. UsersController PUT #update with valid params updates the requested
    user

    Add a hash of attributes valid for your model

    ./spec/controllers/users_

controller_spec.rb:125

Failures:

  1. UsersController PUT #update with invalid params re-renders the
    ‘edit’
    template
    Failure/Error: expect(response).to render_template(“edit”)
    expecting <“edit”> but rendering with <[]>

    ./spec/controllers/users_controller_spec.rb:156:in `block (4

levels)
in <top (required)>’

  1. UsersController POST login renders the login view if params invalid
    Failure/Error: expect(response).to render_template(“login”)
    expecting <“login”> but rendering with <[]>

    ./spec/controllers/users_controller_spec.rb:202:in `block (3

levels)
in <top (required)>’

  1. UsersController POST login populates the @error variable if params
    invalid
    Failure/Error: expect(assigns[:errors].present?).to be(true)

    expected true
    got false

    ./spec/controllers/users_controller_spec.rb:209:in `block (3

levels)
in <top (required)>’

Finished in 1.92 seconds (files took 19.08 seconds to load)
20 examples, 3 failures, 1 pending

Failed examples:

rspec ./spec/controllers/users_controller_spec.rb:153 # UsersController
PUT
#update with invalid params re-renders the ‘edit’ template
rspec ./spec/controllers/users_controller_spec.rb:198 # UsersController
POST login renders the login view if params invalid
rspec ./spec/controllers/users_controller_spec.rb:205 # UsersController
POST login populates the @error variable if params invalid

On Fri, Jun 3, 2016 at 8:21 AM, Michelle McManus
[email protected] wrote:

have a reached a point where I cannot figure out what I’m doing wrong.

  1. UsersController PUT #update with invalid params re-renders the ‘edit’
    template
    Failure/Error: expect(response).to render_template(“edit”)
    expecting <“edit”> but rendering with <[]>

    ./spec/controllers/users_controller_spec.rb:156:in `block (4 levels)

in <top (required)>’

After a quick look, it appears that you’re expecting a validation
failure
on this test, but the “invalid attributes” you’re counting on aren’t –

e.g. instead of

let(:invalid_attributes) {
{
first_name: @user.first_name,
password: @user.password
}
}

(which won’t empty the email that was already set) try

let(:invalid_attributes) {
{
first_name: @user.first_name,
password: @user.password,
email: nil
}
}

and your save will fail.

HTH!

Hassan S. ------------------------ [email protected]

twitter: @hassan
Consulting Availability : Silicon Valley or remote