(PDOC-126) Add spec test for util module and scrub_string method

This commit is contained in:
Will Hopper 2016-10-26 16:34:14 -07:00
parent e291f8cfe9
commit c4705d9705
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
require 'spec_helper'
require 'puppet-strings/yard'
describe PuppetStrings::Yard::Util do
subject {PuppetStrings::Yard::Util}
describe 'scrub_string' do
it 'should remove `%Q` and its brackets from a string ' do
str = "%Q{this is a test string}"
expect(subject.scrub_string(str)).to eq('this is a test string')
end
it 'should remove `%q` and its brackets from a string' do
str = "%q{this is a test string}"
expect(subject.scrub_string(str)).to eq('this is a test string')
end
it 'should not affect newlines when %Q notation is used' do
str = <<-STR
%Q{this is
a test string}
STR
expect(subject.scrub_string(str)).to eq("this is\na test string")
end
it 'should not affect a string which does not use %Q notation' do
str = "this is a test string"
expect(subject.scrub_string(str)).to eq('this is a test string')
end
end
end