Remove body_as_json
in favor of built-in response.parsed_body
for JSON response specs (#31749)
This commit is contained in:
parent
be77a1098b
commit
6b6a80b407
107 changed files with 422 additions and 413 deletions
|
@ -30,7 +30,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
it 'returns an empty list' do
|
||||
subject
|
||||
|
||||
expect(body_as_json).to be_empty
|
||||
expect(response.parsed_body).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
it 'returns the correct canonical email hashes' do
|
||||
subject
|
||||
|
||||
expect(body_as_json.pluck(:canonical_email_hash)).to match_array(expected_email_hashes)
|
||||
expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes)
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
|
@ -50,7 +50,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
it 'returns only the requested number of canonical email blocks' do
|
||||
subject
|
||||
|
||||
expect(body_as_json.size).to eq(params[:limit])
|
||||
expect(response.parsed_body.size).to eq(params[:limit])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,7 +62,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
|
||||
canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s)
|
||||
|
||||
expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[2..])
|
||||
expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[2..])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
|
||||
canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s)
|
||||
|
||||
expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[..2])
|
||||
expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[..2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -96,7 +96,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
id: eq(canonical_email_block.id.to_s),
|
||||
canonical_email_hash: eq(canonical_email_block.canonical_email_hash)
|
||||
|
@ -142,7 +142,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[0][:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
expect(response.parsed_body.first[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -151,7 +151,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to be_empty
|
||||
expect(response.parsed_body).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -173,7 +173,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
|
||||
context 'when the required email param is not provided' do
|
||||
|
@ -193,7 +193,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:canonical_email_hash]).to eq(params[:canonical_email_hash])
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(params[:canonical_email_hash])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -204,7 +204,7 @@ RSpec.describe 'Canonical Email Blocks' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue