Thanks,
I have now this :
require "spec_helper"
describe ProductsController do
describe "GET #index" do
context "with params[:product]", :type => :controller do
it "populates a array containing that product" do
product = create(:product, title: "Book 1")
get :index , product: "Book 1"
expect(assigns(:product)).to match_array(["Book 1"])
end
end
end
end
But I see this error message :
1) ProductsController GET #index with params[:product] populates a array containing that product
Failure/Error: expect(assigns(:product)).to match_array(["Book 1"])
expected a collection that can be converted to an array with `#to_ary` or `#to_a`, but got nil
# ./spec/controllers/products_controller_spec.rb:12:in `block (4 levels) in <top (required)>'
Roelof