0
當運行我的測試時,它實際上並沒有創建新的指南。我看不出有什麼我失蹤,就好象我把所有的屬性...測試沒有創建新的指南
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>.
模型guideline.rb
attr_accessible :content, :hospital, :title, :user_id, :guideline_id, :specialty
guidelines_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: "[email protected]"
base_hospital: "Rottem Hospital"
profile_name: "jjrotten"
encrypted_password: "password"
感謝,這是它 – tessad 2013-02-21 00:19:19