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
我究竟做錯了什麼?