2015-08-13 57 views
0
describe "#index" do 

     it "creates an array of voices" do 
      voice = FactoryGirl.create(:voice) 
      get :index 
      expect(assigns(voices)).to eq([voice]) 
     end 

    end 

我有以上RSpec的,用線expect(assigns(voices)).to eq([voice])看是否@voices包含所有的聲音在我的index行動的數組。RSpec的分配返回undefined局部變量錯誤

當前它返回一個NameError: undefined local variable or method 'voices',但我不明白爲什麼。

我的索引操作非常簡單,

def index 
    @voices = Voice.all 
end 

我究竟做錯了什麼?

回答

0

想通了。

可謂是一個錯字..它象徵:voicesvoices

的正確實施是assigns(:voices)