From c4705d9705cc521bdab596a3399815130d3350d5 Mon Sep 17 00:00:00 2001 From: Will Hopper Date: Wed, 26 Oct 2016 16:34:14 -0700 Subject: [PATCH] (PDOC-126) Add spec test for util module and scrub_string method --- spec/unit/puppet-strings/yard/util_spec.rb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/unit/puppet-strings/yard/util_spec.rb diff --git a/spec/unit/puppet-strings/yard/util_spec.rb b/spec/unit/puppet-strings/yard/util_spec.rb new file mode 100644 index 0000000..65da303 --- /dev/null +++ b/spec/unit/puppet-strings/yard/util_spec.rb @@ -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