Hi, any idea what could cause the following error in a controller
test?
"count should have been changed by 1, but was changed by 0"
I’m posting to a create route using a lambda, similar to Hartl’s
example in his Rails tutorial:
it “should create a user” do
lambda do
post :create, :user => @attr
end.should change(User, :count).by(1)
end
The only difference is I’m using a factory instead of an attribute
hash. I know the action works because I can perform it manually and my
model specs pass.
More importantly, I can see the inserts (two rows, parent and child)
in my Postgres logs. And I see a rollback before the count is
selected. Could that be the cause? [I searched for a while and didn’t
see much discussion about this, so probably not.]