【发布时间】:2014-05-02 02:20:09
【问题描述】:
这里的第二个测试通过了,第一个没有。不知道为什么。
require 'spec_helper'
RSpec.describe UserNotesController do
context 'GET #index' do
let(:note) { build(:user_note) }
specify 'populates an array of notes' do
expect(:user_notes).to eq [note]
end
specify 'renders the :index view' do
get :index
expect(response).to render_template :index
end
end
end
不知道为什么它没有通过,但我收到了这条消息。
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[#<UserNote id: nil, user_id: 2, creator_id: nil, note: "Magnam quas fugit nihil.", created_at: nil, updated_at: nil, follow_up: nil>]
+:user_notes
我对 Rspec 还是很陌生。有什么帮助吗?
【问题讨论】:
-
你没有描述你用什么来模拟数据库。
标签: ruby-on-rails ruby ruby-on-rails-3 rspec