Skip to content

Files

Latest commit

 

History

History
80 lines (61 loc) · 1.32 KB

RSpec-HookArgument.md

File metadata and controls

80 lines (61 loc) · 1.32 KB

Pattern: Inconsistent hook argument

Issue: -

Description

Checks the arguments passed to before, around, and after.

This rule checks for consistent style when specifying RSpec hooks which run for each example. There are three supported styles: "implicit", "each", and "example." All styles have the same behavior.

Examples

when configuration is EnforcedStyle: implicit

# bad
before(:each) do
  # ...
end

# bad
before(:example) do
  # ...
end

# good
before do
  # ...
end

when configuration is EnforcedStyle: each

# bad
before(:example) do
  # ...
end

# good
before do
  # ...
end

# good
before(:each) do
  # ...
end

when configuration is EnforcedStyle: example

# bad
before(:each) do
  # ...
end

# bad
before do
  # ...
end

# good
before(:example) do
  # ...
end

Configurable attributes

Name Default value Configurable values
EnforcedStyle implicit implicit, each, example

Further Reading