0
@sponge = Factory(:user)
let(:event_type) { EventType.where(name: 'visit_site').first
ONE: =>假,当运行测试rspec,2种方式是一样的吗?
subject{ Event.new user: @sponge, event_type: event_type, points_earned: event_type.points_value, description: {}}
context 'call #update_user_points when create a event' do
it{should_receive(:update_user_points)}
end
二: =>真当运行测试
it 'should call update_user_points after creation' do
event = Event.new user: @sponge, event_type: event_type, points_earned:event_type.points_value, description: {}
event.should_receive(:update_user_points)
event.save
end
给我一些建议,请:d
我明白rspec中的一个小例子,为什么我们必须在“event.save”之前放置“should_receive”。我认为它在创建事件后运行update_user_points,它应该在那之后放置?而我虽然第一种方式必须运行良好? 你能带我学些关于RSpec的东西给初学者吗? 谢谢:D – 2012-03-15 01:47:54