Skip to content

Commit

Permalink
Merge pull request #1651 from rubocop/refactor-regex
Browse files Browse the repository at this point in the history
Use `\A` instead of `^` in `RSpec/PredicateMatcher`
  • Loading branch information
pirj authored May 31, 2023
2 parents cd6a30e + abc465e commit 74b8747
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rspec/predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def to_predicate_matcher(name)
name[0..-2]
when 'exist?', 'exists?'
'exist'
when /^has_/
when /\Ahas_/
name.sub('has_', 'have_')[0..-2]
else
"be_#{name[0..-2]}"
Expand Down Expand Up @@ -240,10 +240,10 @@ def to_predicate_method(matcher)
'include?'
when 'respond_to'
'respond_to?'
when /^have_(.+)/
when /\Ahave_(.+)/
"has_#{Regexp.last_match(1)}?"
else
"#{matcher[/^be_(.+)/, 1]}?"
"#{matcher[/\Abe_(.+)/, 1]}?"
end
end
# rubocop:enable Metrics/MethodLength
Expand Down

0 comments on commit 74b8747

Please sign in to comment.