RSpec check the count of an array

You could also turn it around a bit into the following:

expect(assigns(:products)).to have_attributes(count: be_positive)

This allows you to use subject, like this for example:

subject { assigns(:products) }

it { is_expected.to have_attributes(count: be_positive) }

Try

expect(assigns(:products)).to_not be_empty

This works because the array responds to empty?. Another way could be

expect(assigns(:products).count).to be_positive

Because integers respond to positive?

While if you wanted to check an actual count

expect(assigns(:products).count).to eq 1