Rubocop: RSpecRails/HaveHttpStatus

This commit is contained in:
Daniel O'Connor
2026-04-23 14:13:47 +00:00
parent accab7f84c
commit 8de6b083f9
5 changed files with 7 additions and 18 deletions

View File

@@ -472,17 +472,6 @@ RSpec/VerifiedDoubles:
- 'spec/controllers/gardens_controller_spec.rb'
- 'spec/views/devise/shared/_links_spec.rb'
# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ResponseMethods.
# ResponseMethods: response, last_response
RSpecRails/HaveHttpStatus:
Exclude:
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
- 'spec/controllers/harvests_controller_spec.rb'
- 'spec/controllers/likes_controller_spec.rb'
- 'spec/requests/harvests_spec.rb'
# Offense count: 30
# Configuration parameters: Database.
# SupportedDatabases: mysql, postgresql

View File

@@ -42,7 +42,7 @@ RSpec.describe Api::V1::PlantingsController do
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
it { expect(matching_planting['attributes']).to eq expected_attributes }
it { expect(response.status).to eq 200 }
it { expect(response).to have_http_status :ok }
end
context 'with photo' do
@@ -81,7 +81,7 @@ RSpec.describe Api::V1::PlantingsController do
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
it { expect(matching_planting['attributes']).to eq expected_attributes }
it { expect(response.status).to eq 200 }
it { expect(response).to have_http_status :ok }
end
end
end

View File

@@ -51,7 +51,7 @@ describe HarvestsController, :search do
describe "generates a csv" do
before { get :index, format: "csv" }
it { expect(response.status).to eq 200 }
it { expect(response).to have_http_status :ok }
end
end

View File

@@ -19,7 +19,7 @@ describe LikesController do
it { JSON.parse(response.body)["description"] == "1 like" }
describe "Liking someone else's post" do
it { expect(response.code).to eq('201') }
it { expect(response).to have_http_status(:created) }
end
end
@@ -29,14 +29,14 @@ describe LikesController do
it { expect(response.content_type).to eq "application/json; charset=utf-8" }
describe "un-liking something i liked before" do
it { expect(response.code).to eq('200') }
it { expect(response).to have_http_status(:ok) }
it { JSON.parse(response.body)["description"] == "0 likes" }
end
describe "Deleting someone else's like" do
let(:like) { create(:like) }
it { expect(response.code).to eq('403') }
it { expect(response).to have_http_status(:forbidden) }
it { JSON.parse(response.body)["error"] == "Unable to like" }
end
end

View File

@@ -6,7 +6,7 @@ describe "Harvests" do
describe "GET /harvests" do
it "works! (now write some real specs)" do
get harvests_path
expect(response.status).to be 200
expect(response).to have_http_status :ok
end
end
end