我有以下请求规范
it "updates an open time" do
# Create an OpenTime
open_time = OpenTime.create(:start_time => (Time.now + 2.hours), :end_time => (Time.now + 10.hours))
# Build an open_time update param
params = {:open_time => {:start_time => (Time.now + 5.hours)}}
# Send param to open_times#update
put open_time_path(open_time.id) , params
# Check to see if OpenTime was updated
open_time.should_receive(:update_attributes).with({:start_time => (Time.now + 5.hours)})
end
这是我的 open_times 控制器
def update
@open_time = OpenTime.find(params[:id])
if @open_time.update_attributes(params[:open_time])
flash[:success] = "Time updated."
redirect_to @open_time
else
render 'edit'
end
end
测试失败,预期:1 收到:0