2014-03-14 00:31:24 -04:00
|
|
|
require_relative 'helper'
|
2013-02-01 04:24:01 -05:00
|
|
|
|
|
|
|
describe Pry::Helpers::DocumentationHelpers do
|
|
|
|
before do
|
|
|
|
@helper = Pry::Helpers::DocumentationHelpers
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "get_comment_content" do
|
|
|
|
it "should strip off the hash and unindent" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.get_comment_content(" # hello\n # world\n")).to eq("hello\nworld\n")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should strip out leading lines of hashes" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.get_comment_content("###############\n#hello\n#world\n")).to eq("hello\nworld\n")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should remove shebangs" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.get_comment_content("#!/usr/bin/env ruby\n# This is a program\n")).to eq("This is a program\n")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should unindent past separators" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.get_comment_content(" # Copyright Me <me@cirw.in>\n #--\n # So there.\n")).to eq("Copyright Me <me@cirw.in>\n--\nSo there.\n")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "process_rdoc" do
|
|
|
|
before do
|
2014-04-29 03:03:15 -04:00
|
|
|
Pry.config.color = true
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2014-04-29 03:03:15 -04:00
|
|
|
Pry.config.color = false
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should syntax highlight indented code" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc(" 4 + 4\n")).not_to eq(" 4 + 4\n")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should highlight words surrounded by +s" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("the +parameter+")).to match(/the \e.*parameter\e.*/)
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should syntax highlight things in backticks" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("for `Example`")).to match(/for `\e.*Example\e.*`/)
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should emphasise em tags" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("for <em>science</em>")).to eq("for \e[1mscience\e[0m")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should emphasise italic tags" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("for <i>science</i>")).to eq("for \e[1mscience\e[0m")
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should syntax highlight code in <code>" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("for <code>Example</code>")).to match(/for \e.*Example\e.*/)
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
2015-06-24 09:36:03 -04:00
|
|
|
it "should syntax highlight code in <tt>" do
|
|
|
|
expect(@helper.process_rdoc("for <tt>Example</tt>")).to match(/for \e.*Example\e.*/)
|
|
|
|
end
|
|
|
|
|
2013-02-01 04:24:01 -05:00
|
|
|
it "should not double-highlight backticks inside indented code" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc(" `echo 5`")).to match(/echo 5/)
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not remove ++" do
|
2015-03-10 16:49:29 -04:00
|
|
|
expect(@helper.process_rdoc("--\n comment in a bubble\n++")).to match(/\+\+/)
|
2013-02-01 04:24:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-14 00:31:24 -04:00
|
|
|
end
|