Failed test expectation
<p>I have a carts controller in my app</p>

<pre><code>class CartsController &lt; ApplicationController
  def show
    @cart = Cart.find(session[:cart_id])
    @products = @cart.products
  end
end
</code></pre>

<p>and wrote test cartscontroller_spec.rb</p>

<pre><code>RSpec.describe CartsController, type: :controller do
  describe 'GET #show' do
    let(:cart_full_of){ create(:cart_with_products, products_count: 3)}
    before do
      get :show
    end
    it { expect(response.status).to eq(200) }
    it { expect(response.headers["Content-Type"]).to eql("text/html; charset=utf-8")}
    it { is_expected.to render_template :show }
    it 'should be products in current cart' do
      expect(assigns(:products)).to eq(cart_full_of.products)
    end
  end
end
</code></pre>

<p>My factories.rb looks such:</p>

<pre><code>factory(:cart) do |f|
  f.factory(:cart_with_products) do
    transient do
      products_count 5
    end
    after(:create) do |cart, evaluator|
      create_list(:product, evaluator.products_count, carts: [cart])
    end
  end
end

factory(:product) do |f|
  f.name('__product__')
  f.description('__well-description__')
  f.price(100500)
end 
</code></pre>

<p>but I have got an error:</p>

<pre><code>FCartsController GET #show should be products in current cart
Failure/Error: expect(assigns(:products)).to eq(cart_full_of.products)

   expected: #&lt;ActiveRecord::Associations::CollectionProxy [#&lt;Product id: 41, name: "MyProduct", description: "Pro...dDescription", price: 111.0, created_at: "2016-11-24 11:18:43", updated_at: "2016-11-24 11:18:43"&gt;]&gt;
        got: #&lt;ActiveRecord::Associations::CollectionProxy []&gt;
</code></pre>

<p>Looks like  I have no created products at all because of empty product model array ActiveRecord::Associations::CollectionProxy [], simultaneously, I investigate product`s id is increasing with every test attempt.At the moment I have no solid ideas that is wrong</p>