I am very new to RSpec and obviously something is wrong.
Has a base controller with index action:
class TransactionsController < ApplicationController before_filter :authenticate_user! def index @transactions = current_user.transactions respond_to do |format| format.html { render layout: "items" }
And check the default RSpec test for index action.
require 'spec_helper' describe TransactionsController do describe "GET index" do it "assigns all transactions as @transactions" do transaction = FactoryGirl.create(:transaction) get :index assigns(:transactions).should eq([transaction]) end end end
So everything works, except that the line assigns(:transactions).should eq([transaction]) returns nil, so I get this error:
Failure/Error: assigns(:transactions).should eq([transaction]) expected: [
Thank you for any advice as I spent all day on this.
source share