diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-05-08 00:13:29 +0300 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-05-08 00:14:20 +0300 |
commit | cd1a9bbe5eaac5d4a08c76e34605309d5d9e7bcb (patch) | |
tree | ff86fbe6ea03a92ae426d168538409833ec241fd /spec | |
parent | 18c45d26c55a659461c13a5f423f1a5094a74571 (diff) | |
download | pry-cd1a9bbe5eaac5d4a08c76e34605309d5d9e7bcb.tar.gz |
Fix offences of the Style/FrozenStringLiteralComment cop
Fixes #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most
operations)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/command_integration_spec.rb | 1 | ||||
-rw-r--r-- | spec/commands/play_spec.rb | 23 | ||||
-rw-r--r-- | spec/helpers/table_spec.rb | 3 | ||||
-rw-r--r-- | spec/hooks_spec.rb | 10 | ||||
-rw-r--r-- | spec/pryrc_spec.rb | 2 | ||||
-rw-r--r-- | spec/wrapped_module_spec.rb | 13 |
6 files changed, 29 insertions, 23 deletions
diff --git a/spec/command_integration_spec.rb b/spec/command_integration_spec.rb index c1b63052..7579da62 100644 --- a/spec/command_integration_spec.rb +++ b/spec/command_integration_spec.rb @@ -452,7 +452,6 @@ describe "commands" do ) do klass = Pry::CommandSet.new do command "hello", "", keep_retval: true do - eval_string.replace("6") 7 end end diff --git a/spec/commands/play_spec.rb b/spec/commands/play_spec.rb index 000f6fe5..04573eb9 100644 --- a/spec/commands/play_spec.rb +++ b/spec/commands/play_spec.rb @@ -37,6 +37,7 @@ describe "play" do it 'should play a file' do @t.process_command 'play spec/fixtures/whereami_helper.rb' expect(@t.eval_string).to eq unindent(<<-STR) + # frozen_string_literal: true # rubocop:disable Layout/EmptyLineBetweenDefs class Cor def a; end @@ -50,16 +51,18 @@ describe "play" do it 'should output file contents with print option' do @t.process_command 'play --print spec/fixtures/whereami_helper.rb' - expect(@t.last_output).to eq unindent(<<-STR) - 1: # rubocop:disable Layout/EmptyLineBetweenDefs - 2: class Cor - 3: def a; end - 4: def b; end - 5: def c; end - 6: def d; end - 7: end - 8: # rubocop:enable Layout/EmptyLineBetweenDefs - STR + expect(@t.last_output).to eq( + " 1: \# frozen_string_literal: true\n" \ + " 2: \n" \ + " 3: \# rubocop:disable Layout/EmptyLineBetweenDefs\n" \ + " 4: class Cor\n" \ + " 5: def a; end\n" \ + " 6: def b; end\n" \ + " 7: def c; end\n" \ + " 8: def d; end\n" \ + " 9: end\n" \ + "10: \# rubocop:enable Layout/EmptyLineBetweenDefs\n" + ) end end diff --git a/spec/helpers/table_spec.rb b/spec/helpers/table_spec.rb index 66b3acfa..aad9ed6b 100644 --- a/spec/helpers/table_spec.rb +++ b/spec/helpers/table_spec.rb @@ -22,7 +22,8 @@ describe 'Formatting Table' do def try_round_trip(expected) things = expected.split(/\s+/).sort actual = Pry::Helpers.tablify(things, FAKE_COLUMNS).to_s.strip - [expected, actual].each { |e| e.gsub!(/\s+$/, '') } + expected = expected.gsub(/\s+$/, '') + actual = actual.gsub(/\s+$/, '') if actual != expected bar = '-' * 25 puts \ diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb index 0b8d6f9c..16af79a4 100644 --- a/spec/hooks_spec.rb +++ b/spec/hooks_spec.rb @@ -123,14 +123,14 @@ describe Pry::Hooks do end it 'should preserve hook order' do - name = "" + name = '' h1 = Pry::Hooks.new - h1.add_hook(:test_hook, :testing3) { name << "h" } - h1.add_hook(:test_hook, :testing4) { name << "n" } + h1.add_hook(:test_hook, :testing3) { name += "h" } + h1.add_hook(:test_hook, :testing4) { name += "n" } h2 = Pry::Hooks.new - h2.add_hook(:test_hook, :testing1) { name << "j" } - h2.add_hook(:test_hook, :testing2) { name << "o" } + h2.add_hook(:test_hook, :testing1) { name += "j" } + h2.add_hook(:test_hook, :testing2) { name += "o" } h2.merge!(h1) h2.exec_hook(:test_hook) diff --git a/spec/pryrc_spec.rb b/spec/pryrc_spec.rb index a7b5fc2a..59f2eed9 100644 --- a/spec/pryrc_spec.rb +++ b/spec/pryrc_spec.rb @@ -39,7 +39,7 @@ describe Pry do it "should not load the pryrc if pryrc's directory permissions do not allow this" do Dir.mktmpdir do |dir| File.chmod 0o000, dir - Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc') + stub_const('Pry::LOCAL_RC_FILE', File.join(dir, '.pryrc')) Pry.config.should_load_rc = true expect do Pry.start(self, input: StringIO.new("exit-all\n"), output: StringIO.new) diff --git a/spec/wrapped_module_spec.rb b/spec/wrapped_module_spec.rb index a97affb9..138b9b1a 100644 --- a/spec/wrapped_module_spec.rb +++ b/spec/wrapped_module_spec.rb @@ -185,7 +185,8 @@ describe Pry::WrappedModule do describe ".singleton_class?" do it "should be true for singleton classes" do - expect(Pry::WrappedModule.new(class << ""; self; end).singleton_class?).to eq true + mod = Pry::WrappedModule.new(class << Object.new; self; end) + expect(mod).to be_singleton_class end it "should be false for normal classes" do @@ -204,10 +205,12 @@ describe Pry::WrappedModule do end it "should return the attached object" do - expect(Pry::WrappedModule.new(class << "hi"; self; end).singleton_instance) - .to eq "hi" - expect(Pry::WrappedModule.new(class << Object; self; end).singleton_instance) - .to equal(Object) + instance = Object.new + mod = class << instance; self; end + expect(Pry::WrappedModule.new(mod).singleton_instance).to eq(instance) + + klass = class << Object; self; end + expect(Pry::WrappedModule.new(klass).singleton_instance).to equal(Object) end end |