Hello, 

I try to test my controller so I made this :"

require "spec_helper"
describe ProductsController do 
    
    describe "GET #index" do 
        
        context "with params[:product]" do
            
            it "populates a array containing that product"
                product = create(:product, title: "Book 1")
                get :index , product: "Book 1"
                expect(assigns(:product)).to match_array(["Book 1"])
            end
            
            it "renders the :index view"
    end
    
end

But as soon as I run rspec I see this error message ; 

/home/codio/workspace/commerce-try/spec/controllers/products_controller_spec.rb:10:in
 `block (3 levels) in <top (required)>': undefined method `create' for 
#<Class:0x007
fa7da640148> (NoMethodError)  

Which I find wierd because on the model test spec I also use create and 
there no error message 

Roelof

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/1eaf8531-7dd2-4eee-8405-3655981c65ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to