Skip to content

Commit

Permalink
Auto corrected by following Lint Ruby Performance/RegexpMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome Code committed Feb 1, 2021
1 parent 9998514 commit 5f241f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rspec/its_to_it.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@
with_node type: 'block', caller: { message: 'its' } do
if node.body.length == 1
its_arg = node.caller.arguments.first.to_source
its_arg = its_arg[1...-1] if its_arg =~ /^['"].*['"]$/
its_arg = its_arg[1...-1] if /^['"].*['"]$/.match?(its_arg)
its_arg = its_arg[1..-1] if its_arg[0] == ':'
rewritten_code = ''
args = its_arg.split('.')
args.each_with_index do |arg, index|
describe_name = arg[0] =~ /^[a-z]/ ? '#' + arg : arg
message_name = arg[0] =~ /^[a-z]/ ? '.' + arg : arg
describe_name = /^[a-z]/.match?(arg[0]) ? '#' + arg : arg
message_name = /^[a-z]/.match?(arg[0]) ? '.' + arg : arg
rewritten_code << "#{' ' * index}describe '#{describe_name}' do\n"
rewritten_code << "#{' ' * (index + 1)}subject { super()#{message_name} }\n"
rewritten_code << "#{' ' * (index + 1)}it { {{body}} }\n" if index + 1 == args.length
Expand Down

0 comments on commit 5f241f2

Please sign in to comment.