Skip to content

Commit

Permalink
Link fixes and cleanup for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Mar 20, 2023
1 parent 9dd337a commit d4858f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
4 changes: 1 addition & 3 deletions 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:
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions features/controller_specs/README.md
Expand Up @@ -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)
Expand Down
36 changes: 17 additions & 19 deletions features/directory_structure.feature
Expand Up @@ -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
Expand All @@ -43,21 +43,20 @@ 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
```

**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
Expand All @@ -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
Expand All @@ -82,16 +81,15 @@ 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
end
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
Expand Down

0 comments on commit d4858f4

Please sign in to comment.