DEV: Improve tests to provide better errors when it fails.

This commit is contained in:
Guo Xiang Tan 2018-11-13 16:48:04 +08:00
parent e28af0429c
commit d5df1db3c4
1 changed files with 9 additions and 3 deletions

View File

@ -839,11 +839,17 @@ describe PostsController do
raw = "this is a test post 123 #{SecureRandom.hash}"
title = "this is a title #{SecureRandom.hash}"
post "/posts.json", params: { raw: raw, title: title, wpid: 1 }
expect do
post "/posts.json", params: { raw: raw, title: title, wpid: 1 }
end.to change { Post.count }
expect(response.status).to eq(200)
post "/posts.json", params: { raw: raw, title: title, wpid: 2 }
expect(response).not_to be_successful
expect do
post "/posts.json", params: { raw: raw, title: title, wpid: 2 }
end.to_not change { Post.count }
expect(response.status).to eq(422)
end
it 'can not create a post in a disallowed category' do