我該如何幹這個規格?如何幹這個RSpec控制器規格?
describe Api::TasksController, type: :controller do
it 'allows the creator of a task to destroy it' do
set_request_auth_header @user
delete :destroy, id: @task.id
expect(response).to be_success
expect(Task.count).to eq 0
end
it 'does not allow the assignee of a task to destroy it' do
set_request_auth_header @assignee
delete :destroy, id: @task.id
expect(response).to be_forbidden
expect(Task.count).to eq 1
end
it 'does not allow anyone unrelated to a task to destroy it' do
set_request_auth_header @spy
delete :destroy, id: @task.id
expect(response).to be_forbidden
expect(Task.count).to eq 1
end
end
我認爲這個代碼審查將是一個更合適的網站爲這一個:http://codereview.stackexchange.com/ – arjabbar
我不知道這個網站!謝謝。 –