From e1dea2fef907f9a1a03e9cef1acbab8d2911bf88 Mon Sep 17 00:00:00 2001 From: Patrick Derichs Date: Thu, 6 Jun 2019 13:14:18 +0200 Subject: Refactor spec so it separates status code check and content check --- spec/requests/api/task_completion_status_spec.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/requests/api/task_completion_status_spec.rb b/spec/requests/api/task_completion_status_spec.rb index 4739e2cbe2b..c23beeb0211 100644 --- a/spec/requests/api/task_completion_status_spec.rb +++ b/spec/requests/api/task_completion_status_spec.rb @@ -50,18 +50,23 @@ describe 'task completion status response' do } ] samples.each do |sample_data| - it "returns a valid task list status #{sample_data}" do - taskable.update!(description: sample_data[:description]) + context "#{sample_data}" do + before do + taskable.update!(description: sample_data[:description]) - get api("#{path}?iids[]=#{taskable.iid}", user) + get api("#{path}?iids[]=#{taskable.iid}", user) + end - expect(response).to have_gitlab_http_status(200) - expect(json_response).to be_an Array - expect(json_response).not_to be_empty + it { expect(response).to have_gitlab_http_status(200) } - task_completion_status = json_response.first['task_completion_status'] - expect(task_completion_status['count']).to be(sample_data[:expected_count]) - expect(task_completion_status['completed_count']).to be(sample_data[:expected_completed_count]) + it "returns the expected results" do + expect(json_response).to be_an Array + expect(json_response).not_to be_empty + + task_completion_status = json_response.first['task_completion_status'] + expect(task_completion_status['count']).to eq(sample_data[:expected_count]) + expect(task_completion_status['completed_count']).to eq(sample_data[:expected_completed_count]) + end end end end -- cgit v1.2.1