1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

rubocop: fix offences of the Style/VariableInterpolation cop

This commit is contained in:
Kyrylo Silin 2019-03-02 17:01:04 +02:00
parent 49827934ea
commit b07d3252dc
5 changed files with 13 additions and 22 deletions

View file

@ -314,15 +314,6 @@ Style/PerlBackrefs:
- 'lib/pry/method.rb'
- 'lib/pry/rubygem.rb'
# Offense count: 17
# Cop supports --auto-correct.
Style/VariableInterpolation:
Exclude:
- 'spec/commands/edit_spec.rb'
- 'spec/editor_spec.rb'
- 'spec/integration/hanami_spec.rb'
- 'spec/integration/readline_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/WhileUntilModifier:

View file

@ -46,7 +46,7 @@ describe "edit" do
pry_eval 'edit lib/pry.rb'
expect(@file).to eq File.expand_path('lib/pry.rb')
pry_eval "edit #@tf_path"
pry_eval "edit #{@tf_path}"
expect(@file).to eq @tf_path
end
@ -80,7 +80,7 @@ describe "edit" do
File.open(file.gsub('bar.rb', 'baz.rb'), 'w') { |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" }
nil
}
pry_eval "edit #@tf_path"
pry_eval "edit #{@tf_path}"
expect(Pad.required).to eq true
end
end
@ -660,7 +660,7 @@ describe "edit" do
it "should work for a class method" do
def_before, def_after =
apply_monkey_patch(X.method(:x), "#@edit X.x")
apply_monkey_patch(X.method(:x), "#{@edit} X.x")
expect(def_before).to eq ':double_yup'
expect(def_after).to eq ':double_yup'
@ -669,7 +669,7 @@ describe "edit" do
it "should work for an instance method" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:x), "#@edit X#x")
apply_monkey_patch(X.instance_method(:x), "#{@edit} X#x")
expect(def_before).to eq ':nope'
expect(def_after).to eq ':nope'
@ -678,7 +678,7 @@ describe "edit" do
it "should work for a method on an instance" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:x), 'instance = X.new', "#@edit instance.x")
apply_monkey_patch(X.instance_method(:x), 'instance = X.new', "#{@edit} instance.x")
expect(def_before).to eq ':nope'
expect(def_after).to eq ':nope'
@ -687,7 +687,7 @@ describe "edit" do
it "should work for a method from a module" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:a), "#@edit X#a")
apply_monkey_patch(X.instance_method(:a), "#{@edit} X#a")
expect(def_before).to eq ':yup'
expect(def_after).to eq ':yup'
@ -696,7 +696,7 @@ describe "edit" do
it "should work for a method with a question mark" do
def_before, def_after =
apply_monkey_patch(X.instance_method(:y?), "#@edit X#y?")
apply_monkey_patch(X.instance_method(:y?), "#{@edit} X#y?")
expect(def_before).to eq ':because'
expect(def_after).to eq ':because'
@ -705,7 +705,7 @@ describe "edit" do
it "should work with nesting" do
def_before, def_after =
apply_monkey_patch(X::B.instance_method(:foo), "#@edit X::B#foo")
apply_monkey_patch(X::B.instance_method(:foo), "#{@edit} X::B#foo")
expect(def_before).to eq '_foo = :possibly'
expect(def_after).to eq '_foo = :possibly'

View file

@ -25,7 +25,7 @@ describe Pry::Editor do
describe "build_editor_invocation_string", skip: !Pry::Helpers::Platform.windows? do
it 'should shell-escape files' do
invocation_str = @editor.build_editor_invocation_string(@tf_path, 5, true)
expect(invocation_str).to match(/#@tf_dir.+hello\\ world\.rb/)
expect(invocation_str).to match(/#{@tf_dir}.+hello\\ world\.rb/)
end
end

View file

@ -31,7 +31,7 @@ RSpec.describe "Hanami integration" do
Timeout.timeout(1) { Action.new.call("define prison, in the abstract sense") }
exit 42
RUBY
`#@ruby -I#@pry_dir -e'#{code}'`
`#{@ruby} -I#{@pry_dir} -e'#{code}'`
expect($CHILD_STATUS.exitstatus).to eq(42)
end
end

View file

@ -14,7 +14,7 @@ RSpec.describe "Readline" do
require "pry"
p defined?(Readline)
RUBY
expect(`#@ruby -I #@pry_dir -e '#{code}'`).to eq("nil\n")
expect(`#{@ruby} -I #{@pry_dir} -e '#{code}'`).to eq("nil\n")
end
it "is loaded on invoking 'pry'" do
@ -23,7 +23,7 @@ RSpec.describe "Readline" do
Pry.start self, input: StringIO.new("exit-all"), output: StringIO.new
puts defined?(Readline)
RUBY
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("constant\n")).to eq(true)
expect(`#{@ruby} -I #{@pry_dir} -e '#{code}'`.end_with?("constant\n")).to eq(true)
end
it "is not loaded on invoking 'pry' if Pry.input is set" do
@ -33,6 +33,6 @@ RSpec.describe "Readline" do
Pry.start self, output: StringIO.new
p defined?(Readline)
RUBY
expect(`#@ruby -I #@pry_dir -e '#{code}'`.end_with?("nil\n")).to eq(true)
expect(`#{@ruby} -I #{@pry_dir} -e '#{code}'`.end_with?("nil\n")).to eq(true)
end
end