Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Update README.md with shared context loading example #3051

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ pretty much the same as `shared_examples` and `include_examples`, providing
more accurate naming when you share hooks, `let` declarations, helper methods,
etc, but no examples.

If you want to reuse shared context between multipple specs you can put it into
a file(`foo.rb`) under a separate directory(`spec/support/shared_contexts`).
In this case you have to require the context in each spec with
```ruby
require 'spec/support/shared_contexts/foo.rb'
```
or you can require every context inside the directory by placing this code
```ruby
Dir['spec/support/**/*.rb'].each do |f|
require File.expand_path(f)
end
```
into the _spec_helper.rb_ file.

The directory structure and the way ruby files are included completely depends
on your needs.

DDKatch marked this conversation as resolved.
Show resolved Hide resolved
## Metadata

rspec-core stores a metadata hash with every example and group, which
Expand Down
Loading