【发布时间】:2015-05-02 00:30:08
【问题描述】:
在我的Dashboard#Index 我的控制器中有这个:
tagged_nodes = Node.includes(:user_tags).tagged_with(current_user.email)
这是我的规格:
it "assigns all the nodes that are tagged with the current_user email to local variable 'tagged_nodes'" do
get :index
expect(assigns(:tagged_users)).to eq Node.includes(:user_tags).tagged_with(@user.email)
end
这是我得到的错误:
Failure/Error: expect(assigns(:tagged_users)).to eq Node.includes(:user_tags).tagged_with(@user.email)
expected: #<ActiveRecord::Relation []>
got: nil
(compared using ==)
我怀疑这是因为 tagged_with 是来自 gem acts_as_taggable_on 的辅助方法
这确实是导致此错误的原因吗?如果是这样,我该如何解决?
如果不是,是什么导致了这个错误?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 rspec acts-as-taggable-on rspec3