diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c1d34c237..d4e10e9f5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 diff --git a/spec/controllers/api/v1/plantings_controller_spec.rb b/spec/controllers/api/v1/plantings_controller_spec.rb index 49a009e2b..35bf65d22 100644 --- a/spec/controllers/api/v1/plantings_controller_spec.rb +++ b/spec/controllers/api/v1/plantings_controller_spec.rb @@ -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 diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index aca28b883..bb7734fe1 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -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 diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 7389d75cb..278512c71 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -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 diff --git a/spec/requests/harvests_spec.rb b/spec/requests/harvests_spec.rb index 839d588f7..6c796af09 100644 --- a/spec/requests/harvests_spec.rb +++ b/spec/requests/harvests_spec.rb @@ -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