Skip to content

Commit

Permalink
Disable RSpec/NoExpectationExample for feature/system specs
Browse files Browse the repository at this point in the history
[The GOV.UK Rails convention approach for feature/system specs](https://docs.publishing.service.gov.uk/manual/conventions-for-rails-applications.html#featuresystem-testing) have expectations within methods and thus falsely trigger this cop.

For example we think a test like this is valid:

```
  scenario do
    given_i_have_an_active_conversation_with_an_answered_question
    when_i_visit_the_conversation_page
    and_i_click_that_the_answer_was_useful
    then_i_see_that_my_feedback_was_submitted
  end

  def then_i_see_that_my_feedback_was_submitted
    expect(page).to have_content("Feedback submitted successfully.")
  end
```

Whereas this cop would trigger as there are no expectations in the
scenario.
  • Loading branch information
kevindew committed Jun 26, 2024
1 parent 6f199ed commit 1c1ed2a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ RSpec/InstanceVariable:
- 'spec/features/**/*.rb'
- 'spec/system/**/*.rb'

# The GOV.UK Feature spec style has expectations in method calls so this
# cop falsely triggers.
RSpec/NoExpectationExample:
Exclude:
- 'spec/features/**/*.rb'
- 'spec/system/**/*.rb'

# In GOV.UK we quite often test that a class received a method.
RSpec/MessageSpies:
Enabled: false
Expand All @@ -56,7 +63,7 @@ RSpec/ContextWording:
# scenario.
# We don't want this cop outside of feature or system specs though.
RSpec/Dialect:
# Disables all Capybara-specific methods that have the same native
# Disables all Capybara-specific methods that have the same native
# RSpec method (e.g. are just aliases)
PreferredMethods:
background: :before
Expand Down

0 comments on commit 1c1ed2a

Please sign in to comment.