Skip to content

Conversation

@github-actions
Copy link
Contributor

Rubocop challenge!

RSpec/ImplicitSubject

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Checks for usage of implicit subject (is_expected / should).

This cop can be configured using the EnforcedStyle option

Examples

EnforcedStyle: single_line_only (default)

# bad
it do
  is_expected.to be_truthy
end

# good
it { is_expected.to be_truthy }
it do
  expect(subject).to be_truthy
end

EnforcedStyle: single_statement_only

# bad
it do
  foo = 1
  is_expected.to be_truthy
end

# good
it do
  foo = 1
  expect(subject).to be_truthy
end
it do
  is_expected.to be_truthy
end

EnforcedStyle: disallow

# bad
it { is_expected.to be_truthy }

# good
it { expect(subject).to be_truthy }

EnforcedStyle: require_implicit

# bad
it { expect(subject).to be_truthy }

# good
it { is_expected.to be_truthy }

# bad
it do
  expect(subject).to be_truthy
end

# good
it do
  is_expected.to be_truthy
end

# good
it { expect(named_subject).to be_truthy }

Auto generated by rubocop_challenger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant