ブラウザでテストすると実際には動作するのに、失敗するテストがあります。私のテストに何か問題があるようです。
私はshouldaとフィクスチャを使用しています。
require 'test_helper'
class AddressesControllerTest < ActionController::TestCase
context 'on PUT to :update' do
setup do
put(:update, {
:id => addresses(:mary_publics_address).id,
:street1 => '123 Now St.'
}, { :user_id => users(:stan).id})
end
should 'update the Address' do
a = Address.find(addresses(:mary_publics_address).id)
assert(a.street1 == '123 Now St.', 'Attribute did not get updated.')
end
end
end
「属性が更新されませんでした」で失敗します。
テスト中のコントローラーコードは次のとおりです。
class AddressesController < ApplicationController
def update
@address = Address.find(params[:id])
@address.update_attributes!(params[:address])
render(:text => "Address with ID #{params[:id]} updated")
end
end