Skip to content

shared_examples with js: true are wrongfully included in js: true contexts #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ojab opened this issue Mar 16, 2016 · 2 comments
Closed

Comments

@ojab
Copy link
Contributor

ojab commented Mar 16, 2016

In this test:

RSpec.shared_examples :shared_test, js: true do
  it { expect(true).to eq(false) }
end

RSpec.feature 'Test feature' do
  context 'Test context', js: true do
    it { expect(true).to eq(true) }
  end
end

:shared_test examples are executed in Test context, although we're not including it.

@ojab
Copy link
Contributor Author

ojab commented Mar 16, 2016

(Reproducible in both 3.4.2 and git master)

@myronmarston
Copy link
Member

This is working by design. Shared group metadata was intended to be used for automatic inclusion in matching groups when the feature was first written. It's a problematic design, though, and we plan to change it. See rspec/rspec-core#1790.

For now, you can work around it like so:

RSpec.shared_examples :shared_test do
  context "some context", js: true do
    it { expect(true).to eq(false) }
  end
end

By putting the metadata on a nested group instead of the shared group itself, it avoids the auto-inclusion. Hopefully we'll implement the solution discussed in rspec/rspec-core#1790 soon.

myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
myronmarston added a commit to rspec/rspec-core that referenced this issue Jun 5, 2016
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes #1790 (this is the last thing necessary for it).
- Addresses #1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this issue Oct 30, 2020
Previously, it always triggered auto-inclusion based on
matching metadata. The option allows you to opt-in to having
it add the metadata to included groups and examples instead.

- Closes rspec#1790 (this is the last thing necessary for it).
- Addresses rspec#1762.
- Addresses user confusion reported in:
  - rspec/rspec-rails#1241
  - rspec/rspec-rails#1579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants