rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Feature Request: Support suffix for RSpec/ContextWording

Open okuramasafumi opened this issue 2 years ago • 0 comments

https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspeccontextwording

Currently only prefix is supported for RSpec/ContextWording, but for some languages, only prefix cannot make description sound natural. I'm a native speaker of Japanese so here I'd like to take Japanese as an example.

description '#some_method' do
  # Bad
  '条件1' do
    # When condition 1 is fulfilled
  end

  # Good
  '条件1が満たされるとき' do
    # When condition 1 is fulfilled
  end
end

Here, the better context for me is the one that ends with 'とき', meaning if or when in Japanese. In general, when rubocop-rspec supports suffix for context wording, it can help writing context in other languages than English. And in some situations, we need to write contexts in our native languages, not English. In addition, RSpec/ContextWording doesn't mean that it only supports prefix. In English, suffix is not important in terms of context. So, the default value for suffix can be empty. With empty default value, we can benefit from restricting suffix while it doesn't effect existing users.

okuramasafumi avatar Aug 05 '22 06:08 okuramasafumi