let(:product) { FactoryGirl.create(:product) }
it "should blah" do
product.name = "a"
product.save!
post :update, id: product.id, product: { name: "x" }
# assuming :update changes the product's name to params[:name]
product.reload.name.should == "x"
end
should
除非我做类似的事情,否则总是失败
Product.find(product.id).name.should == "x"
我在滥用let
吗?
如果我使用@product
created insidebefore :each
就@product.reload
可以了。