2014-03-14 05:31:24 +01:00
|
|
|
require_relative 'helper'
|
2011-05-04 03:49:09 +12:00
|
|
|
|
|
|
|
describe Pry::Helpers::CommandHelpers do
|
|
|
|
before do
|
|
|
|
@helper = Pry::Helpers::CommandHelpers
|
|
|
|
end
|
|
|
|
|
2013-02-01 01:24:01 -08:00
|
|
|
describe "unindent" do
|
|
|
|
it "should remove the same prefix from all lines" do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(@helper.unindent(" one\n two\n")).to eq("one\ntwo\n")
|
2013-02-01 01:24:01 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not be phased by empty lines" do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(@helper.unindent(" one\n\n two\n")).to eq("one\n\ntwo\n")
|
2013-02-01 01:24:01 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should only remove a common prefix" do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(@helper.unindent(" one\n two\n")).to eq(" one\ntwo\n")
|
2013-02-01 01:24:01 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should also remove tabs if present" do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(@helper.unindent("\tone\n\ttwo\n")).to eq("one\ntwo\n")
|
2013-02-01 01:24:01 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should ignore lines starting with --" do
|
2015-03-10 22:49:29 +02:00
|
|
|
expect(@helper.unindent(" one\n--\n two\n")).to eq("one\n--\ntwo\n")
|
2013-02-01 01:24:01 -08:00
|
|
|
end
|
|
|
|
end
|
2011-05-04 03:49:09 +12:00
|
|
|
end
|