Je suis en train de tester mon action de mise à jour Rails avec ceci:fonctionne d'action, mais le test ne fonctionne pas (Shoulda)
context "on PUT to :update" do
setup do
@countdown = Factory(:countdown)
@new_countdown = Factory.stub(:countdown)
put :update, :id => @countdown.id, :name => @new_countdown.name, :end => @new_countdown.end
end
should_respond_with :redirect
should_redirect_to("the countdowns view") { countdown_url(assigns(:countdown)) }
should_assign_to :countdown
should_set_the_flash_to /updated/i
should "save :countdown with new attributes" do
@countdown = Countdown.find(@countdown.id)
assert_equal @new_countdown.name, @countdown.name
assert_equal 0, (@new_countdown.end - @countdown.end).to_i
end
end
Quand je vais en fait à travers le processus de mise à jour en utilisant l'échafaudage qui a été construit il met à jour l'amende record, mais les tests me donnent cette erreur:
1) Failure:
test: on PUT to :update should save :countdown with new attributes. (CountdownsControllerTest)
[/test/functional/countdowns_controller_test.rb:86:in `__bind_1276353837_121269'
/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call'
/Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: on PUT to :update should save :countdown with new attributes. ']:
<"Countdown 8"> expected but was
<"Countdown 7">.
Réalisé cette ligne: 'put: mise à jour,: id => @ compte à rebours.id,: nom => @ nouveau compte.nom,: end => @ nouveau_compte.end' devrait être' put: mise à jour,: id => @ countdown.id,: compte à rebours => {: nom => @ nouveau_nombre.nom,: end => @ nouveau_compte.end} ' – trobrock