I'm using rspec and draper gem https://github.com/jcasimir/draper
In my controller it's a simple action show
def show
@category = Category.find(params[:id])
@products = ProductDecorator.decorate(@category.products)
end
and test
describe "#show" do
before { @category = Factory :category }
before do
@product1 = Factory :product, category: @category
@product2 = Factory :product, category: @category
end
before { get :show, id: @category.id }
it { should respond_with :success }
it { assigns(:products).should eq [@product1, @product2] }
end
In project all works fine and products are displayed normally, but in test I get such error
Failure/Error: it { assigns(:products).should eq [@product1, @product2] }
expected: [#<Product ... >, #<Product ...>]
got: nil
(compared using ==)
also if I replace ProductDecorator.decorate(@category.products) with just @category.products - no errors
if I inspect @products
def show
@category = Category.find(params[:id])
@products = ProductDecorator.decorate(@category.products)
puts @products.inspect
end
got
#<DecoratedEnumerableProxy of ProductDecorator for [#<Product ...>, #<Product ...>]>
Any suggestions?