我很难通过特性/场景rspec仪器测试模型计数。
require 'spec_helper'
feature 'Registration' do
scenario 'Guest can sign up as individual' do
with_role(:guest)
sign_up(:client)
Individual.count.should == 1
# should be replaced by expect{ sign_up(:client) }.to change{ Individual.count }.by(1)
end
end如何在场景中将model.count应该从块中的expect替换为expect?我不想使用time,因为每次使用它都会更改记录计数
你好,亚历克斯
发布于 2014-01-09 16:44:16
使用rspec的更改匹配器的正确方法如下:
expect{ sign_up(:client) }.to change(Individual, :count).by(1)https://stackoverflow.com/questions/20543720
复制相似问题