spec/string-pad_spec.rb in string-pad-0.0.1 vs spec/string-pad_spec.rb in string-pad-0.0.2
- old
+ new
@@ -5,13 +5,17 @@
subject do
'aaa あいうえお zzz'
end
it 'should pad' do
+ regexp_str = String::ZERO_WIDTH_CHARS.map do |c|
+ [c].pack('U')
+ end.join('')
+
size(subject.pad(30)).should eql(30)
# http://www.metareal.org/2007/11/18/ruby-needs-unicode-regular-expressions/
- size(subject.pad(30).gsub(/#{"[#{[0x200b].pack('U')}#{[0x200c].pack('U')}]"}/u, '')).should eql(13)
+ size(subject.pad(30).gsub(/#{"[#{regexp_str}]"}/u, '')).should eql(13)
end
it 'should not pad if original size is longer than padding size' do
size(subject.pad(10)).should eql(13)
end