Please help me to understand why this piece of rspec code is behaving this
way. I am setting product_id to my record, and it is asserting true, but
yet record.product not returning anything.

product = FactoryGirl.create(:product)

post :create, {:tshirt =>
FactoryGirl.attributes_for(:tshirt).stringify_keys.merge("product_id"=>
product.id.to_s) } #successful creation
expect(Tshirt.last.product_id).to eq(product.id)  # asserts true
puts Tshirt.last.product #prints nothing
expect(Tshirt.last.product.size).to eq(product.size)  # exception!!! it
says, product = nil



-- 
 Md. Sadaf Noor (@sadaf2605 <https://twitter.com/sadaf2605>)
 www.sadafnoor.com

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAAJ2eVo1maFsRsNgvefn%3DE4YM5Bz9azEwKTpXkzq1hRt%3DtJuDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to