diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-03-02 15:35:35 +0200 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-03-02 15:42:52 +0200 |
commit | 080d2b0b3a537d50db942170ac4f06cf3687c23e (patch) | |
tree | 2a8e3bb1503d589e0433d08270b59e7554d4afbe /spec/commands | |
parent | 13b10dad3858f3d58d2c5e6dff1473ee870b3e89 (diff) | |
download | pry-080d2b0b3a537d50db942170ac4f06cf3687c23e.tar.gz |
rubocop: fix offences of the Style/SingleLineMethods cop
Diffstat (limited to 'spec/commands')
-rw-r--r-- | spec/commands/edit_spec.rb | 21 | ||||
-rw-r--r-- | spec/commands/gist_spec.rb | 8 | ||||
-rw-r--r-- | spec/commands/show_doc_spec.rb | 12 | ||||
-rw-r--r-- | spec/commands/show_source_spec.rb | 70 | ||||
-rw-r--r-- | spec/commands/whereami_spec.rb | 4 |
5 files changed, 90 insertions, 25 deletions
diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb index 531a55c8..a5a01d5c 100644 --- a/spec/commands/edit_spec.rb +++ b/spec/commands/edit_spec.rb @@ -5,7 +5,9 @@ describe "edit" do @old_editor = Pry.config.editor @file = @line = @contents = nil Pry.config.editor = lambda do |file, line| - @file = file; @line = line; @contents = File.read(@file) + @file = file + @line = line + @contents = File.read(@file) nil end end @@ -141,7 +143,9 @@ describe "edit" do before do @reloading = nil Pry.config.editor = lambda do |file, line, reloading| - @file = file; @line = line; @reloading = reloading + @file = file + @line = line + @reloading = reloading nil end end @@ -162,7 +166,9 @@ describe "edit" do @pry.last_exception = exception end - def last_exception; @pry.last_exception; end + def last_exception + @pry.last_exception + end end end @@ -414,6 +420,7 @@ describe "edit" do tester end + # rubocop:disable Style/SingleLineMethods it 'uses patch editing on methods that were previously patched' do # initial definition tester = pry_tester binding @@ -435,6 +442,7 @@ describe "edit" do # original file is unchanged expect(File.readlines(filename)[line - 1].strip).to eq 'def m; 1; end' end + # rubocop:enable Style/SingleLineMethods it 'can repeatedly edit methods that were defined in the console' do # initial definition @@ -515,7 +523,8 @@ describe "edit" do before do @file = @line = @contents = nil Pry.config.editor = lambda do |file, line| - @file = file; @line = line + @file = file + @line = line nil end end @@ -733,7 +742,9 @@ describe "edit" do before do @file = @line = @reloading = nil Pry.config.editor = lambda do |file, line, reloading| - @file = file; @line = line; @reloading = reloading + @file = file + @line = line + @reloading = reloading nil end end diff --git a/spec/commands/gist_spec.rb b/spec/commands/gist_spec.rb index 5f6a0015..3630dd57 100644 --- a/spec/commands/gist_spec.rb +++ b/spec/commands/gist_spec.rb @@ -13,14 +13,18 @@ describe 'gist' do # In absence of normal mocking, just monkeysmash these with no undoing after. module ::Gist # rubocop:disable Style/ClassAndModuleChildren class << self - def login!; Pad.gist_calls[:login!] = true end + def login! + Pad.gist_calls[:login!] = true + end def gist(*args) Pad.gist_calls[:gist_args] = args { 'html_url' => 'http://gist.blahblah' } end - def copy(content); Pad.gist_calls[:copy_args] = content end + def copy(content) + Pad.gist_calls[:copy_args] = content + end end end diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb index 4153f3a6..76ab44c3 100644 --- a/spec/commands/show_doc_spec.rb +++ b/spec/commands/show_doc_spec.rb @@ -23,7 +23,9 @@ describe "show-doc" do it 'should work even if #call is defined on Symbol' do class Symbol - def call; 5; end + def call + 5 + end end expect(pry_eval(binding, "show-doc @o.sample_method")).to match(/sample doc/) end @@ -474,7 +476,9 @@ describe "show-doc" do # doink-doc class Jingle - def a; :doink; end + def a + :doink + end end class Jangle < Jingle; end @@ -521,7 +525,9 @@ describe "show-doc" do module Jesus # alpha-doc module Alpha - def alpha; :alpha; end + def alpha + :alpha + end end module Zeta; end diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb index d16510e3..b68104d1 100644 --- a/spec/commands/show_source_spec.rb +++ b/spec/commands/show_source_spec.rb @@ -66,7 +66,11 @@ describe "show-source" do end it "should not show the source when a non-extant method is requested" do - _c = Class.new { def method; 98; end } + _c = Class.new do + def method + 98 + end + end expect(mock_pry(binding, "show-source _c#wrongmethod")).to match(/Couldn't locate/) end @@ -82,44 +86,70 @@ describe "show-source" do 98 end - def self.instance_method; 789; end + def self.instance_method + 789 + end end expect(pry_eval(binding, "show-source _c#method")).to match(/98/) end it "should find instance methods with self#moo" do - _c = Class.new { def moo; "ve over!"; end } + _c = Class.new do + def moo + "ve over!" + end + end expect(pry_eval(binding, "cd _c", "show-source self#moo")).to match(/ve over/) end it "should not find instance methods with self.moo" do - _c = Class.new { def moo; "ve over!"; end } + _c = Class.new do + def moo + "ve over!" + end + end expect { pry_eval(binding, 'cd _c', 'show-source self.moo') }.to raise_error(Pry::CommandError, /Couldn't locate/) end it "should find normal methods with self.moo" do - _c = Class.new { def self.moo; "ve over!"; end } + _c = Class.new do + def self.moo + "ve over!" + end + end expect(pry_eval(binding, 'cd _c', 'show-source self.moo')).to match(/ve over/) end it "should not find normal methods with self#moo" do - _c = Class.new { def self.moo; "ve over!"; end } + _c = Class.new do + def self.moo + "ve over!" + end + end expect { pry_eval(binding, 'cd _c', 'show-source self#moo') }.to raise_error(Pry::CommandError, /Couldn't locate/) end it "should find normal methods (i.e non-instance methods) by default" do - _c = Class.new { def self.moo; "ve over!"; end } + _c = Class.new do + def self.moo + "ve over!" + end + end expect(pry_eval(binding, "cd _c", "show-source moo")).to match(/ve over/) end it "should find instance methods if no normal methods available" do - _c = Class.new { def moo; "ve over!"; end } + _c = Class.new do + def moo + "ve over!" + end + end expect(pry_eval(binding, "cd _c", "show-source moo")).to match(/ve over/) end @@ -280,7 +310,9 @@ describe "show-source" do end it "should output source for method objects" do - def @o.hi; puts 'hi world'; end + def @o.hi + puts 'hi world' + end _meth = @o.method(:hi) expect(pry_eval(binding, "show-source _meth")).to match(/puts 'hi world'/) end @@ -700,7 +732,9 @@ describe "show-source" do describe "create_command commands" do it 'should show source for a command' do @set.create_command "foo", "babble" do - def process() :body_of_foo end + def process + :body_of_foo + end end expect(pry_eval('show-source foo')).to match(/:body_of_foo/) end @@ -720,7 +754,9 @@ describe "show-source" do # rubocop:disable Style/ClassAndModuleChildren class ::TemporaryCommand < Pry::ClassCommand match 'temp-command' - def process() :body_of_temp end + def process + :body_of_temp + end end # rubocop:enable Style/ClassAndModuleChildren @@ -763,12 +799,16 @@ describe "show-source" do before do module Jesus module Pig - def lillybing; :lillybing; end + def lillybing + :lillybing + end end class Brian; end class Jingle - def a; :doink; end + def a + :doink + end end class Jangle < Jingle; include Pig; end @@ -820,7 +860,9 @@ describe "show-source" do before do module Jesus module Alpha - def alpha; :alpha; end + def alpha + :alpha + end end module Zeta; end diff --git a/spec/commands/whereami_spec.rb b/spec/commands/whereami_spec.rb index b115c5e2..2b56ece8 100644 --- a/spec/commands/whereami_spec.rb +++ b/spec/commands/whereami_spec.rb @@ -21,7 +21,9 @@ describe "whereami" do pry_eval(binding, 'whereami').should =~ /Cor[#]blimey!/ end - def method; "moo"; end + def method + "moo" + end end Cor.new.blimey! Object.remove_const(:Cor) |