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 7965713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:13:50+00:00 2026-06-04T06:13:50+00:00

When I run this test require ‘spec_helper’ describe AssignmentsController do let(:user) { create(:user) }

  • 0

When I run this test

require 'spec_helper'

describe AssignmentsController do

  let(:user) { create(:user) }
  let(:course) { create(:course) }

  describe "GET 'index'" do
     it "returns http success" do
      assignment = user.assignments.build(name: "Hello 2", start_date: "5/20/2000", due_date: "5/21/2000")
      get :index
      assigns(:assignment).should eq([assignment])
    end
  end
end

I get this
Failure:

  1) AssignmentsController GET 'index' returns http success
     Failure/Error: get :index
     NoMethodError:
       undefined method `assignments' for nil:NilClass
     # ./app/controllers/assignments_controller.rb:5:in `index'
     # ./spec/controllers/assignments_controller_spec.rb:29:in `block (3 levels) in <top (required)>'

Why this be since I defined the user variable with lets above

  • 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-04T06:13:51+00:00Added an answer on June 4, 2026 at 6:13 am

    If you look carefully, you’ll see that the error originating from your controller on line 5, not the spec file. Everything should be fine with the let statement the way you have it.

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

Sidebar

Related Questions

I get this error when I run gradle test : Caused by: org.gradle.api.GradleException: Could
When I run this unit test: require 'test_helper' class MyControllerTest < ActionController::TestCase test "my
My spec require 'spec_helper' describe 'user_sessions/new.html.erb' do let (:user_session) { mock_model(UserSession).as_null_object } before do
I've got a spec/controllers/add_to_carts_spec.rb : require 'spec_helper' describe CartItemsController do before (:each) do @user
I have a problem: if i run this test in NUnit ,it works Board
When I run the this select '$(''test'')' in SQL Management Studio 2008 it returns
I need to run this line from my c++ program: java -jar test.jar text1
I run this piece of code on Visual C++ 2010 char c[10]; cin.get(&c[0],5); cin.get(&c[2],4);
Here is my current users_controller_spec.rb file require 'spec_helper' describe UsersController do render_views . .
When I run this sample from the OptionParser documentation: require 'optparse' options = {}

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.