summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorT.Yasuma <31178796+wakasa51@users.noreply.github.com>2021-10-11 18:10:14 +0900
committerGitHub <noreply@github.com>2021-10-11 12:10:14 +0300
commit5590e095ae97bfed0374ee0e1f58a78dae855d8f (patch)
tree6daaead2d091c232ed6c003703ed89c986db5d06
parent332255a395cbe192b2d834d7230984ef2c89126c (diff)
downloadpry-5590e095ae97bfed0374ee0e1f58a78dae855d8f.tar.gz
fix pry indent frozen error (#2136)
* fix pry indent frozen error * fix generation of mutable strings * fix String.new with no argument * rubocop: fix offences of the Style/EmptyLiteral cop
-rw-r--r--lib/pry/indent.rb2
-rw-r--r--spec/indent_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb
index 963758a6..2d19d87e 100644
--- a/lib/pry/indent.rb
+++ b/lib/pry/indent.rb
@@ -109,7 +109,7 @@ class Pry
# reset internal state
def reset
@stack = []
- @indent_level = ''
+ @indent_level = String.new # rubocop:disable Style/EmptyLiteral
@heredoc_queue = []
@close_heredocs = {}
@string_start = nil
diff --git a/spec/indent_spec.rb b/spec/indent_spec.rb
index 29c07a5f..a705d8bc 100644
--- a/spec/indent_spec.rb
+++ b/spec/indent_spec.rb
@@ -305,6 +305,14 @@ OUTPUT
expect(@indent.indent(input)).to eq output
end
+ it "should not raise error, if MIDWAY_TOKENS are used without indentation" do
+ expect { @indent.indent("when") }.not_to raise_error
+ expect { @indent.reset.indent("else") }.not_to raise_error
+ expect { @indent.reset.indent("elsif") }.not_to raise_error
+ expect { @indent.reset.indent("ensure") }.not_to raise_error
+ expect { @indent.reset.indent("rescue") }.not_to raise_error
+ end
+
describe "nesting" do
test = File.read("spec/fixtures/example_nesting.rb")