extracted method

This commit is contained in:
Hauke Klement
2015-02-09 16:24:33 +01:00
parent 342c3a153c
commit 232c6b398f
5 changed files with 14 additions and 10 deletions

View File

@ -29,7 +29,7 @@ describe ErrorsController do
expect(response.body).to eq({hint: hint}.to_json) expect(response.body).to eq({hint: hint}.to_json)
end end
expect_content_type('application/json') expect_json
expect_status(200) expect_status(200)
end end
@ -46,7 +46,7 @@ describe ErrorsController do
expect { request.call }.to change(Error, :count).by(1) expect { request.call }.to change(Error, :count).by(1)
end end
expect_content_type('application/json') expect_json
expect_status(201) expect_status(201)
end end
end end
@ -55,7 +55,7 @@ describe ErrorsController do
before(:each) { post :create, execution_environment_id: FactoryGirl.build(:error).execution_environment.id, error: {}, format: :json } before(:each) { post :create, execution_environment_id: FactoryGirl.build(:error).execution_environment.id, error: {}, format: :json }
expect_assigns(error: Error) expect_assigns(error: Error)
expect_content_type('application/json') expect_json
expect_status(422) expect_status(422)
end end
end end

View File

@ -67,7 +67,7 @@ describe ExecutionEnvironmentsController do
expect_assigns(docker_client: DockerClient) expect_assigns(docker_client: DockerClient)
expect_assigns(execution_environment: :execution_environment) expect_assigns(execution_environment: :execution_environment)
expect_content_type('application/json') expect_json
expect_status(200) expect_status(200)
end end

View File

@ -154,7 +154,7 @@ describe ExercisesController do
expect(assigns(:submission)).to be_a(Submission) expect(assigns(:submission)).to be_a(Submission)
end end
expect_content_type('application/json') expect_json
expect_status(200) expect_status(200)
end end
@ -170,7 +170,7 @@ describe ExercisesController do
expect(assigns(:submission)).to be_a(Submission) expect(assigns(:submission)).to be_a(Submission)
end end
expect_content_type('application/json') expect_json
expect_status(503) expect_status(503)
end end
end end
@ -188,7 +188,7 @@ describe ExercisesController do
expect(assigns(:submission)).to be_a(Submission) expect(assigns(:submission)).to be_a(Submission)
end end
expect_content_type('application/json') expect_json
expect_status(200) expect_status(200)
end end
end end

View File

@ -21,7 +21,7 @@ describe SubmissionsController do
expect { request.call }.to change(Submission, :count).by(1) expect { request.call }.to change(Submission, :count).by(1)
end end
expect_content_type('application/json') expect_json
expect_status(201) expect_status(201)
end end
@ -29,7 +29,7 @@ describe SubmissionsController do
before(:each) { post :create, submission: {} } before(:each) { post :create, submission: {} }
expect_assigns(submission: Submission) expect_assigns(submission: Submission)
expect_content_type('application/json') expect_json
expect_status(422) expect_status(422)
end end
end end
@ -169,7 +169,7 @@ describe SubmissionsController do
expect_assigns(docker_client: DockerClient) expect_assigns(docker_client: DockerClient)
expect_assigns(submission: :submission) expect_assigns(submission: :submission)
expect_content_type('application/json') expect_json
expect_status(200) expect_status(200)
end end
end end

View File

@ -27,6 +27,10 @@ def expect_flash_message(type, message)
end end
end end
def expect_json
expect_content_type('application/json')
end
def expect_redirect(path = nil) def expect_redirect(path = nil)
if path if path
it "redirects to #{path}" do it "redirects to #{path}" do