From 531a82222a6860ec7fbebb9c46e967d264bd05d0 Mon Sep 17 00:00:00 2001 From: Soyu Kim Date: Wed, 1 May 2024 15:05:55 +0900 Subject: [PATCH 1/2] Fix rubocop errors --- app/controllers/api/v1/base.rb | 2 +- app/controllers/restrooms_controller.rb | 6 +++--- spec/features/restrooms_spec.rb | 8 ++++---- spec/spec_helper.rb | 2 +- spec/support/rspec.rb | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/base.rb b/app/controllers/api/v1/base.rb index ef33d966..86ee4bed 100644 --- a/app/controllers/api/v1/base.rb +++ b/app/controllers/api/v1/base.rb @@ -1,4 +1,4 @@ -# TODO autoloading order changed. This should be managed by configs instead: +# TODO: autoloading order changed. This should be managed by configs instead: # https://guides.rubyonrails.org/v7.0/autoloading_and_reloading_constants.html#autoloading-when-the-application-boots require_relative 'restrooms' diff --git a/app/controllers/restrooms_controller.rb b/app/controllers/restrooms_controller.rb index 76e82c98..721cd4c3 100644 --- a/app/controllers/restrooms_controller.rb +++ b/app/controllers/restrooms_controller.rb @@ -17,6 +17,8 @@ def index end end + def show; end + # rubocop:disable Metrics/MethodLength def new if params[:edit_id] @@ -33,7 +35,7 @@ def new end # rubocop:enable Metrics/MethodLength - def show; end + def edit; end # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength @@ -69,8 +71,6 @@ def create # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength - def edit; end - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength def update diff --git a/spec/features/restrooms_spec.rb b/spec/features/restrooms_spec.rb index b2a69ab5..9c095d5a 100644 --- a/spec/features/restrooms_spec.rb +++ b/spec/features/restrooms_spec.rb @@ -47,7 +47,7 @@ visit root_path fill_in 'search', with: 'San Francisco' - click_on 'Search' + click_button 'Search' expect(page).to have_content 'Mission Creek Cafe' end @@ -57,7 +57,7 @@ visit root_path mock_location "Oakland" - click_on 'Search by Current Location' + click_button 'Search by Current Location' expect(page).not_to have_content 'Some Cafe' end @@ -99,7 +99,7 @@ fill_in "restroom[state]", with: "British Columbia" find(:select, "Country").first(:option, "Canada").select_option - click_on "Preview" + click_button "Preview" page.has_css?(".nearby-container .listItem", visible: :visible) end @@ -136,7 +136,7 @@ click_link "Propose an edit to this listing." fill_in "restroom[directions]", with: "This is an edit" - click_on "Save Restroom" + click_button "Save Restroom" expect(page).to have_content("Your edit has been submitted.") expect(Restroom.where(edit_id: restroom.id).size).to eq(2) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 094b3f3f..4ef41a21 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,7 +30,7 @@ # config.mock_with :rr # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = Rails.root.join("/spec/fixtures") # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/support/rspec.rb b/spec/support/rspec.rb index 2ce2f539..d0190e37 100644 --- a/spec/support/rspec.rb +++ b/spec/support/rspec.rb @@ -5,7 +5,7 @@ # spec/spec_helper.rb # -require_relative './locations' +require_relative 'locations' Capybara.register_driver :poltergeist_debug do |app| Capybara::Poltergeist::Driver.new( From 25e0df4924c5352b2f495858fd055a990b1642e5 Mon Sep 17 00:00:00 2001 From: Soyu Kim Date: Sun, 5 May 2024 23:14:52 +0900 Subject: [PATCH 2/2] Fix rubocop-rspec errors, enabling to infer spec type from file location --- spec/api/v1/restrooms_spec.rb | 2 +- spec/controllers/pages_controller_spec.rb | 2 +- spec/controllers/restrooms_controller_spec.rb | 2 +- spec/features/contacts_spec.rb | 2 +- spec/features/restrooms_spec.rb | 2 +- spec/spec_helper.rb | 2 ++ 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/api/v1/restrooms_spec.rb b/spec/api/v1/restrooms_spec.rb index 23329a55..578d7cdf 100644 --- a/spec/api/v1/restrooms_spec.rb +++ b/spec/api/v1/restrooms_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Restrooms API", type: :request do +describe API::V1::Restrooms do it 'sends a list of restrooms order by date descending' do create_list(:restroom, 15) diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 4ddcd738..36bc3adf 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe PagesController, type: :controller do +describe PagesController do it_behaves_like 'localized request', :index it "#index" do diff --git a/spec/controllers/restrooms_controller_spec.rb b/spec/controllers/restrooms_controller_spec.rb index 1ba2372b..ec51c97e 100644 --- a/spec/controllers/restrooms_controller_spec.rb +++ b/spec/controllers/restrooms_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe RestroomsController, type: :controller do +describe RestroomsController do it_behaves_like 'localized request', :index it "#index" do diff --git a/spec/features/contacts_spec.rb b/spec/features/contacts_spec.rb index b3a6b89f..bd5e5eae 100644 --- a/spec/features/contacts_spec.rb +++ b/spec/features/contacts_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'the contact process', type: :feature do +describe 'the contact process' do it 'shows a generic contact when contact is not from restroom form' do restroom = create(:restroom, name: "Mission Creek Cafe") diff --git a/spec/features/restrooms_spec.rb b/spec/features/restrooms_spec.rb index 9c095d5a..e343fa8c 100644 --- a/spec/features/restrooms_spec.rb +++ b/spec/features/restrooms_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'restrooms', type: :feature, js: true do +describe 'restrooms', :js do describe 'submission' do it 'adds a restroom when submitted' do visit root_path diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4ef41a21..332ead25 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,6 +37,8 @@ # instead of true. config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run.