Skip to content

Files

Latest commit

 

History

History
40 lines (28 loc) · 974 Bytes

RSpec-LeadingSubject.md

File metadata and controls

40 lines (28 loc) · 974 Bytes

Pattern: Malformed use of subject

Issue: -

Description

Enforce that subject is the first definition in the test.

Examples

# bad
  let(:params) { blah }
  subject { described_class.new(params) }

  before { do_something }
  subject { described_class.new(params) }

  it { expect_something }
  subject { described_class.new(params) }
  it { expect_something_else }

# good
  subject { described_class.new(params) }
  let(:params) { blah }

# good
  subject { described_class.new(params) }
  before { do_something }

# good
  subject { described_class.new(params) }
  it { expect_something }
  it { expect_something_else }

Further Reading