You're not stubbing the right thing - your error indicates that something is attempting to call the method []
(i.e. array or hash dereferencing) on your double @customer
.
Check your code and see whether you are sending a []
to a customer object anywhere.
Are you positive the last line should not be
@customer.stub(:[]).with(:subscription).and_return { [@subscription] }
instead?