在运行我的测试时,它实际上并没有创建新的指南。我根本看不到我缺少什么,因为我拥有所有属性...
1) Failure:
test_should_create_guideline_when_logged_in(GuidelinesControllerTest) [test/functional/guidelines_controller_test.rb:47]:
"Guideline.count" didn't change by 1.
<4> expected but was
<3>.
模型指南.rb
attr_accessible :content, :hospital, :title, :user_id, :guideline_id, :specialty
guides_controller_test.rb
test "should create guideline when logged in" do
sign_in users(:testuser)
assert_difference('Guideline.count') do
post :create, guideline: { content: @guideline.content, hospital: @guideline.hospital, title: @guideline.title, user_id: users(:testuser).id, specialty: @guideline.specialty }
end
assert_redirected_to guideline_path(assigns(:guideline))
end
固定装置/users.yml
testuser:
first_name: "Jonny"
last_name: "Rotten"
email: "jonnyrotten@gmail.com"
base_hospital: "Rottem Hospital"
profile_name: "jjrotten"
encrypted_password: "password"