ruby on rails - undefined local variable or method `user' for #<Class:0x00000007dc99c8> (NameError) -
I am writing a test to check whether the login creates a random account for the user. This is the schema for the database:
ActiveRecord :: Schema.define (version: 20141015163624) do # is the extension that should enable this database to enable_extension "plpgsql" create_table " Users ", Force: True | T | T.string "name" t.string "email" t.datetime "created_at" t.datetime "updated_at" t.string "password_digest" t.string "remember_digest" end add_index "users", ["email"], name: Using "Index_users_on_email", Unique: Correct, :: btree end and this is a test file:
requires 'rails_helper' RSpec.describe "UserPages",: Type = & gt; : Before "signup" before {signup_path} please describe "valid information", before filling "name", with "example user" fill_in "email": "user@example.com" fill_in "password "," Fobar "fill_in with" password confirmation ":" foobar "end description" after saving the user "to {click_button submit} before (user) {user.find_by (email:'user@example.com) ')} Please describe "Remember Remember" (user.remember_digest) .not_to be_blank end end end but I get this error on running rspec: < / P> in block (5 levels) & lt; Top (required) & gt; ': Undefined local variable or method # for user & lt; Class: 0x00000007dc99c8 & gt; (Name enter)
before the user (: each) Or before (: all) . It also appears that the created object form is outside the scope of submission.
Try:
Before describing "signup", go to {signup_path} ({.}) Before "valid information" (all :) "fill_in" With "example user" fill_in "email" before: "user@example.com" fill_in "password" with: "foobar" fill_in "confirm password", with: "foobar" click_button submit it " Digest value is missing "hopefully (user.find_by_email ('user@example.com ')). If it is not working, it is probably because you do not have access to the user class within your XPC.
Comments
Post a Comment