出于某种原因,我的规范没有通过。似乎@categories
没有达到规范。
这是控制器:
class CategoriesController < ApplicationController
def index
@categories = Category.all
end
end
我的规格:
require 'spec_helper'
describe CategoriesController do
describe "GET #index" do
category = FactoryGirl.create(:category)
subject { get :index }
it { @categories.should include category }
end
end
错误:
Failure/Error: @categories.should include category
NoMethodError:
undefined method `include?' for nil:NilClass