我是新來的紅寶石在rails上,我一直在閱讀rails書的敏捷web開發。 我正在研究迭代B1:驗證,並且我正在進行測試時對符號:產品感到困惑。問題是關於「:product => @update」 我真的不知道這是什麼意思,以及產品符號來自哪裏。我知道這是一個散列,但它散列到哪個表?它究竟在這裏做什麼?代碼如下。先謝謝你。敏捷web開發與rails ProductsControllerTest,含義:產品符號
require 'test_helper'
class ProductsControllerTest < ActionController::TestCase
setup do
@product = products(:one)
@update = {
:title => 'Lorem Ipsum',
:description => 'Wibbles are fun!',
:image_url => 'lorem.jpg',
:price => 19.95
}
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:products)
end
test "should get new" do
get :new
assert_response :success
end
test "should create product" do
assert_difference('Product.count') do
***post :create, :product => @update***
end
assert_redirected_to product_path(assigns(:product))
end
# ...
test "should show product" do
get :show, :id => @product.to_param
assert_response :success
end
test "should get edit" do
get :edit, :id => @product.to_param
assert_response :success
end
test "should update product" do
put :update, :id => @product.to_param, :product => @update
assert_redirected_to product_path(assigns(:product))
end
# ...
test "should destroy product" do
assert_difference('Product.count', -1) do
delete :destroy, :id => @product.to_param
end
assert_redirected_to products_path
end
end