I'm trying to check multiple conditions over the same execution, in this case is just a post( :create , user: user.attributes ) but I would like to know in general what's the best approach.
Here is the complete example
describe UsersController do
describe 'CRUDL' do
describe 'create' do
let(:user) { User.new(username: "created") }
let(:response) { post( :create , user: user.attributes ) }
it 'should respond with created(201) http message' do
response.code.should == "201"
end
it 'should increment total users count' do
expect{ response }.to change{User.count}.by(1)
end
end
end
The expect{ response }.to change{User.count}.by(1) part does not seem right. What would be the correct approach to test many assertion over the same code execution?