Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:57:26+00:00 2026-06-15T20:57:26+00:00

I am failing 3 tests and I have found numerous examples on here and

  • 0

I am failing 3 tests and I have found numerous examples on here and on on the internet in general but I can’t seem to find where I’m going wrong. Thanks for any help.

1) User pages signup with valid information edit page 
 Failure/Error: before { visit edit_user_path(user) }
 ActionView::Template::Error:
   undefined method `model_name' for NilClass:Class
 # ./app/views/users/edit.html.erb:6:in  `_app_views_users_edit_html_erb___4113112884365867193_70232486166220'
 # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'

2) User pages signup with valid information edit page 
 Failure/Error: before { visit edit_user_path(user) }
 ActionView::Template::Error:
   undefined method `model_name' for NilClass:Class
 # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220'
 # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'

3) User pages signup with valid information edit page 
 Failure/Error: before { visit edit_user_path(user) }
 ActionView::Template::Error:
   undefined method `model_name' for NilClass:Class
 # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220'
 # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>'

Finished in 0.26515 seconds
3 examples, 3 failures

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:100 # User pages signup with valid information edit page 
rspec ./spec/requests/user_pages_spec.rb:99 # User pages signup with valid information edit page 
rspec ./spec/requests/user_pages_spec.rb:101 # User pages signup with valid information edit page 

authentication_pages_spec.rb

    require 'spec_helper'

 describe "Authentication" do

 subject { page }

 describe "signin page" do
  before { visit signin_path }

  it { should have_selector('h1',    text: 'Sign in') }
  it { should have_selector('title', text: 'Sign in') }
end

describe "signin" do
before { visit signin_path }

describe "with invalid information" do
  before { click_button "Sign in" }

  it { should have_selector('title', text: 'Sign in') }
  it { should have_selector('div.alert.alert-error', text: 'Invalid') }

  describe "after visiting another page" do
    before { click_link "Home" }
    it { should_not have_selector('div.alert.alert-error') }
  end
end

describe "with valid information" do
  let(:user) { FactoryGirl.create(:user) }
  before do
    fill_in "Email", with: user.email
    fill_in "Password", with: user.password
    click_button "Sign in"
  end



  it { should have_selector('title', text: user.name) }
  it { should have_link('Profile', href: user_path(user)) }
  it { should have_link('Sign out', href: signout_path) }
  it { should_not have_link('Sign in', href: signin_path) }

  describe "followed by signout" do
    before { click_link "Sign out" }
    it { should have_link('Sign in') }
  end
 end
end


end  

Here is the users_controller:

    class UsersController < ApplicationController

 def show
   @user = User.find(params[:id])
 end

 def new
    @user = User.new
 end

 def create
     @user = User.new(params[:user])
    if @user.save
    sign_in @user
  flash[:success] = "Welcome to the Sample App!"
  redirect_to @user
else
  render 'new'
  end
 end
end

 def edit
     @user = User.find(params[:id])
 end      

edit.html.erb:

  <% provide(:title, "Edit user") %> 
  <h1>Update your profile</h1>

<div class="row">
 <div class="span6 offset3">
  <%= form_for(@user) do |f| %>
  <%= render 'shared/error_messages' %>

  <%= f.label :name %>
  <%= f.text_field :name %>

  <%= f.label :email %>
  <%= f.text_field :email %>

  <%= f.label :password %>
  <%= f.password_field :password %>

  <%= f.label :password_confirmation, "Confirm Password" %>
  <%= f.password_field :password_confirmation %>

   <%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
  <% end %>

    <%= gravatar_for @user %>
  <a href="http://gravatar.com/emails">change</a>
 </div>

here is the user_pages_spec:

    require 'spec_helper'

describe "User pages" do

subject { page }

describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }

it { should have_selector('h1', text: user.name) }
it { should have_selector('title', text: user.name) }
end

describe "signup page" do
 before { visit signup_path }

it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end

describe "signup" do

before { visit signup_path }

describe "with invalid information" do
it "should not create a user" do
  expect { click_button "Create my account" }.not_to change(User, :count)
end

describe "error messages" do
  before { click_button "Create my account" }

  it { should have_selector('title', text: 'Sign up') }
  it { should have_content('error') }
 end
end

 describe "with valid information" do
  before do
    fill_in "Name", with: "Example User"
    fill_in "Email", with: "user@example.com"
    fill_in "Password", with: "foobar"
    fill_in "Confirmation", with: "foobar"
 end

 it "should create a user" do
  expect do
    click_button "Create my account"
  end.to change(User, :count).by(1)
 end

 describe "after saving the user" do
  before { click_button "Create my account" }
  let(:user) { User.find_by_email('user@example.com') }

  it { should have_selector('title', text: user.name) }
  it { should have_selector('div.alert.alert-success', text: 'Welcome') }
  it { should have_link('Sign out') }
 end
 end
end

 describe "signup page" do
 before { visit signup_path }

it { should have_selector('h1', text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end

  describe "signup" do

before { visit signup_path }

let(:submit) { "Create my account" }

describe "with invalid information" do
it "should not create a user" do
  expect { click_button submit }.not_to change(User, :count)
 end
end

describe "with valid information" do
before do
  fill_in "Name", with: "Example User"
  fill_in "Email", with: "user@example.com"
  fill_in "Password", with: "foobar"
  fill_in "Confirmation", with: "foobar"
end

it "should create a user" do
  expect { click_button submit }.to change(User, :count).by(1)
end
describe "edit" do
  let(:user) { FactoryGirl.create(:user) }
  before { visit edit_user_path(user) }

  describe "page" do
    it { should have_selector('h1', text: "Update your profile") }
    it { should have_selector('title', text: "Edit user") }
    it { should have_link('change', href: 'http://gravatar.com/emails') }
  end

  describe "with invalid information" do
    before { click_button "Save changes" }

    it { should have_content('error') }
    end
     end
     end
   end
 end

edit: users_controllers.rb was formatted incorrectly. It should look like this:

class UsersController < ApplicationController

 def show
  @user = User.find(params[:id])
 end

def new
 @user = User.new
end

def create
 @user = User.new(params[:user])
 if @user.save
  sign_in @user
  flash[:success] = "Welcome to the Sample App!"
  redirect_to @user
else
  render 'new'
 end
end

def edit
  @user = User.find(params[:id])
 end 
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:57:27+00:00Added an answer on June 15, 2026 at 8:57 pm

    I was ending the class UsersController before the edit action so it didn’t see it. See my edit at bottom of OP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After running bundle update I have suddenly found that my cucumber tests are failing
I have a series of NUnit tests and some are failing, yet I can't
I must be going out of my mind, because my unit tests are failing
I have been debugging some existing code for which unit tests are failing on
We’ve found that the unit tests we’ve written for our C#/C++ code have really
I have found that the following : <junit haltonfailure=no haltonerror=no > <!-- some tests
I have a simple test case failing in Django: Model (app/models.py): from django.db import
I'm getting a bunch of failing tests (21 to be exact)/ an error message
redirect_to is failing for me in my cucumber tests. The step_definition method is Then
Possible Duplicate: strtotime failing on mm-dd-yyyy hh:mm I have a date coming in like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.