Vote count:
0
I'm building my API using Rails + Grape and I'm trying to rspec the PUT and DELETE routes. This is what my test looks like and it's failing:
describe "API::V1::User" do
let(:user) { FactoryGirl.create :user }
describe "PUT /users/:id" do
expect{ put "/users/#{user.id}", name: 'New Name' }.to change{user.reload.name}
end
describe "DELETE /users/:id" do
user # lazy load user
expect{ delete "/users/#{user.id}"}.to change{User.count}.by(1)
end
end
So is the expect{} not being evaluated before the 'to' method is being called? Or is the http request still being processed which is why the database hasn't actually changed?
asked 53 secs ago
Aucun commentaire:
Enregistrer un commentaire