Is there a way to force RSpec to re-evaluate a let statement?
You can just define a regular method:
def number_of_users
User.count
end
it 'counts users' do
User.create
number_of_users.should == 1
User.create
number_of_users.should == 2
end
See this blog post for some more details, including how to store the helper methods in a separate module.
How about writing such test like this:
it "counts user" do
expect {
User.create
}.to change(User, :count).by(1)
end