mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
rubocop: fix offences of the Lint/InterpolationCheck cop
This commit is contained in:
parent
f92e221bbc
commit
08fa0dcb5d
7 changed files with 29 additions and 17 deletions
|
@ -22,16 +22,6 @@ Lint/HandleExceptions:
|
|||
- 'lib/pry/pager.rb'
|
||||
- 'lib/pry/terminal.rb'
|
||||
|
||||
# Offense count: 16
|
||||
Lint/InterpolationCheck:
|
||||
Exclude:
|
||||
- 'spec/command_integration_spec.rb'
|
||||
- 'spec/command_set_spec.rb'
|
||||
- 'spec/command_spec.rb'
|
||||
- 'spec/commands/amend_line_spec.rb'
|
||||
- 'spec/commands/edit_spec.rb'
|
||||
- 'spec/pry_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/Loop:
|
||||
Exclude:
|
||||
|
|
|
@ -236,7 +236,9 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
expect(pry_tester(commands: set).eval('hello #{Pad.bong}')).to match(/bong/)
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
|
||||
# bug fix for https://github.com/pry/pry/issues/170
|
||||
|
@ -245,7 +247,10 @@ describe "commands" do
|
|||
"is a command"
|
||||
) do
|
||||
redirect_pry_io(
|
||||
InputTester.new('/#{Regexp.escape(File.expand_path("."))}/'), @str_output
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
InputTester.new('/#{Regexp.escape(File.expand_path("."))}/'),
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
@str_output
|
||||
) do
|
||||
pry
|
||||
end
|
||||
|
@ -260,16 +265,19 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
expect(pry_tester(commands: set).eval('hello #{Pad.bong}'))
|
||||
.to match(/Pad\.bong/)
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
|
||||
it 'should NOT try to interpolate pure ruby code (no commands) ' do
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
# These should raise RuntimeError instead of NameError
|
||||
expect { pry_eval 'raise \'#{aggy}\'' }.to raise_error RuntimeError
|
||||
expect { pry_eval 'raise #{aggy}' }.to raise_error RuntimeError
|
||||
|
||||
expect { pry_eval 'raise #{aggy}' }.to raise_error RuntimeError
|
||||
expect(pry_eval('format \'#{my_var}\'')).to eq "\#{my_var}"
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
|
||||
it 'should create a command with a space in its name zzz' do
|
||||
|
@ -326,7 +334,7 @@ describe "commands" do
|
|||
end
|
||||
|
||||
bong = "bong"
|
||||
expect(pry_tester(binding, commands: set).eval('hello #{bong}'))
|
||||
expect(pry_tester(binding, commands: set).eval("hello #{bong}"))
|
||||
.to match(/hello #{bong}/)
|
||||
end
|
||||
|
||||
|
@ -342,7 +350,7 @@ describe "commands" do
|
|||
bang = 'bang'
|
||||
|
||||
expect(pry_tester(binding, commands: set)
|
||||
.eval('hellojohn #{bing} #{bong} #{bang}'))
|
||||
.eval("hellojohn #{bing} #{bong} #{bang}"))
|
||||
.to match(/hello john #{bing} #{bong} #{bang}/)
|
||||
end
|
||||
|
||||
|
|
|
@ -575,7 +575,9 @@ describe Pry::CommandSet do
|
|||
|
||||
it 'should not cause argument interpolation' do
|
||||
@set.command('hello')
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
expect { @set.valid_command?('hello #{raise "futz"}') }.to_not raise_error
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -315,12 +315,14 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
describe 'tokenize' do
|
||||
it 'should interpolate string with #{} in them' do
|
||||
it "should interpolate string with \#{} in them" do
|
||||
expect do |probe|
|
||||
cmd = @set.command('random-dent', &probe)
|
||||
|
||||
_foo = 5
|
||||
cmd.new(target: binding).process_line 'random-dent #{1 + 2} #{3 + _foo}'
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
cmd.new(target: binding).process_line('random-dent #{1 + 2} #{3 + _foo}')
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end.to yield_with_args('3', '8')
|
||||
end
|
||||
|
||||
|
@ -333,11 +335,13 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should not interpolate commands with :interpolate => false' do
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
expect do |probe|
|
||||
cmd = @set.command('thor', 'norse god', interpolate: false, &probe)
|
||||
|
||||
cmd.new.process_line 'thor %(#{foo})'
|
||||
end.to yield_with_args('%(#{foo})')
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
|
||||
it 'should use shell-words to split strings' do
|
||||
|
|
|
@ -97,7 +97,9 @@ describe "amend-line" do
|
|||
puts :bang
|
||||
STR
|
||||
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
@t.process_command 'amend-line puts "#{goodbye}"'
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
|
||||
expect(@t.eval_string).to eq unindent(<<-'STR')
|
||||
def hello
|
||||
|
|
|
@ -726,7 +726,11 @@ describe "edit" do
|
|||
before do
|
||||
Pry.config.editor = lambda do |file, _line|
|
||||
lines = File.read(file).lines.to_a
|
||||
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
lines[1] = '"#{super}aa".to_sym' + "\n"
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
|
||||
File.open(file, 'w') do |f|
|
||||
f.write(lines.join)
|
||||
end
|
||||
|
|
|
@ -318,7 +318,9 @@ describe Pry do
|
|||
a.to_i + 1
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/InterpolationCheck
|
||||
expect(mock_pry('++ 86', '++ #{_}')).to match(/88/)
|
||||
# rubocop:enable Lint/InterpolationCheck
|
||||
end
|
||||
|
||||
it "should be preserved over an empty line" do
|
||||
|
|
Loading…
Reference in a new issue