Skip to content

Commit 74b8747

Browse files
authored
Merge pull request #1651 from rubocop/refactor-regex
Use `\A` instead of `^` in `RSpec/PredicateMatcher`
2 parents cd6a30e + abc465e commit 74b8747

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/rubocop/cop/rspec/predicate_matcher.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def to_predicate_matcher(name)
7474
name[0..-2]
7575
when 'exist?', 'exists?'
7676
'exist'
77-
when /^has_/
77+
when /\Ahas_/
7878
name.sub('has_', 'have_')[0..-2]
7979
else
8080
"be_#{name[0..-2]}"
@@ -240,10 +240,10 @@ def to_predicate_method(matcher)
240240
'include?'
241241
when 'respond_to'
242242
'respond_to?'
243-
when /^have_(.+)/
243+
when /\Ahave_(.+)/
244244
"has_#{Regexp.last_match(1)}?"
245245
else
246-
"#{matcher[/^be_(.+)/, 1]}?"
246+
"#{matcher[/\Abe_(.+)/, 1]}?"
247247
end
248248
end
249249
# rubocop:enable Metrics/MethodLength

0 commit comments

Comments
 (0)