From d4858f4a30c4f4d38aab8cee58250ecc11786c76 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 20 Mar 2023 14:51:28 +0000 Subject: [PATCH] Link fixes and cleanup for docs --- features/.nav | 4 +--- features/controller_specs/README.md | 8 +++---- features/directory_structure.feature | 36 +++++++++++++--------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/features/.nav b/features/.nav index 7afd8ad003..0af57bfb15 100644 --- a/features/.nav +++ b/features/.nav @@ -1,8 +1,6 @@ - GettingStarted.md (Start from scratch) - Generators.md (Generators) - Transactions.md -- Changelog.md -- RailsVersions.md (Rails versions) - directory_structure.feature - backtrace_filtering.feature - model_specs: @@ -11,7 +9,7 @@ - mock_model.feature - stub_model.feature - controller_specs: - - Cookies.md + - cookies.feature - controller_spec.feature - isolation_from_views.feature - render_views.feature diff --git a/features/controller_specs/README.md b/features/controller_specs/README.md index 1044309af9..e789fc2408 100644 --- a/features/controller_specs/README.md +++ b/features/controller_specs/README.md @@ -19,22 +19,22 @@ To specify outcomes, you can use: - standard test/unit assertions (`assert_equal 200, response.status`) - rails assertions (`assert_response 200`) - rails-specific matchers: - - [`render_template`](matchers/render-template-matcher) + - [`render_template`](../matchers/render-template-matcher) ```ruby expect(response).to render_template(:new) # wraps assert_template ``` - - [`redirect_to`](matchers/redirect-to-matcher) + - [`redirect_to`](../matchers/redirect-to-matcher) ```ruby expect(response).to redirect_to(location) # wraps assert_redirected_to ``` - - [`have_http_status`](matchers/have-http-status-matcher) + - [`have_http_status`](../matchers/have-http-status-matcher) ```ruby expect(response).to have_http_status(:created) ``` - - [`be_a_new`](matchers/be-a-new-matcher) + - [`be_a_new`](../matchers/be-a-new-matcher) ```ruby expect(assigns(:widget)).to be_a_new(Widget) diff --git a/features/directory_structure.feature b/features/directory_structure.feature index 2bda425b34..b85e90e92f 100644 --- a/features/directory_structure.feature +++ b/features/directory_structure.feature @@ -3,25 +3,25 @@ Feature: The directory structure Specs are usually placed in a canonical directory structure that describes their purpose: - - [Model specs](model-specs) reside in the `spec/models` directory + - [Model specs](./model-specs) reside in the `spec/models` directory - - [Controller specs](controller-specs) reside in the `spec/controllers` directory + - [Controller specs](./controller-specs) reside in the `spec/controllers` directory - - [Request specs](request-specs) reside in the `spec/requests` directory. The directory can also be named `integration` or `api`. + - [Request specs](./request-specs) reside in the `spec/requests` directory. The directory can also be named `integration` or `api`. - - [Feature specs](feature-specs) reside in the `spec/features` directory + - [Feature specs](./feature-specs) reside in the `spec/features` directory - - [View specs](view-specs) reside in the `spec/views` directory + - [View specs](./view-specs) reside in the `spec/views` directory - - [Helper specs](helper-specs) reside in the `spec/helpers` directory + - [Helper specs](./helper-specs) reside in the `spec/helpers` directory - - [Mailer specs](mailer-specs) reside in the `spec/mailers` directory + - [Mailer specs](./mailer-specs) reside in the `spec/mailers` directory - - [Routing specs](routing-specs) reside in the `spec/routing` directory + - [Routing specs](./routing-specs) reside in the `spec/routing` directory - - [Job specs](job-specs) reside in the `spec/jobs` directory + - [Job specs](./job-specs) reside in the `spec/jobs` directory - - [System specs](system-specs) reside in the `spec/system` directory + - [System specs](./system-specs) reside in the `spec/system` directory Application developers are free to use a different directory structure. In order to include the correct `rspec-rails` support functions, the specs need @@ -43,10 +43,10 @@ Feature: The directory structure `RSpec.describe` block with the `type: :controller` metadata: ```ruby - ​# spec/legacy/things_controller_spec.rb + # spec/legacy/things_controller_spec.rb RSpec.describe ThingsController, type: :controller do describe "GET index" do - ​# Examples + # Examples end end ``` @@ -54,10 +54,9 @@ Feature: The directory structure **Note:** Standard RSpec specs do not require any additional metadata by default. - Check out the [`rspec-core`](/rspec/rspec-core/docs) documentation on [using metadata](/rspec/rspec-core/docs/metadata) for more details. + Check out the [`rspec-core`](../../latest/rspec-core) documentation on [using metadata](../../latest/rspec-core/metadata) for more details. - Automatically Adding Metadata - ----------------------------- + ## Automatically Adding Metadata RSpec versions before 3.0.0 automatically added metadata to specs based on their location on the filesystem. This was both confusing to new users and not @@ -66,7 +65,7 @@ Feature: The directory structure This behaviour must be explicitly enabled: ```ruby - ​# spec/rails_helper.rb + # spec/rails_helper.rb RSpec.configure do |config| config.infer_spec_type_from_file_location! end @@ -82,7 +81,7 @@ Feature: The directory structure If you want to set metadata for a custom directory that doesn't follow fit the canonical structure above, you can do the following: ```ruby - ​# set `:type` for serializers directory + # set `:type` for serializers directory RSpec.configure do |config| config.define_derived_metadata(:file_path => Regexp.new('/spec/serializers/')) do |metadata| metadata[:type] = :serializer @@ -90,8 +89,7 @@ Feature: The directory structure end ``` - Tips on Spec Location - --------------------- + ## Tips on Spec Location It is suggested that the `spec/` directory structure generally mirror both `app/` and `lib/`. This makes it easy to locate corresponding code and spec