Sha256: 8dd84284a25c71de02071fbf7c9577173559fad50e08a5e3b5c9acb6eda1b8aa

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

module NameQ
  module Support
    describe Suffix do
      let(:index) { '88' }
      let(:subject) { described_class.new(index) }
      let(:custom_template) { '-[%{index}]-' }

      describe '#strip' do
        let(:text) { 'How about this' }

        it 'can ignore templateless content' do
          expect(subject.strip(text)).to eq text
        end

        it 'can strip the content of its template' do
          expect(subject.strip("#{text} (7)")).to eq text
        end

        it 'is not tripped up by template-like content' do
          expect(subject.strip("#{text} (7)!")).to eq "#{text} (7)!"
        end

        context 'overridden template' do
          let(:subject) { described_class.new(index, template: custom_template) }

          it 'can strip the content of its template' do
            expect(subject.strip("#{text}-[7]-")).to eq text
          end

          it 'is not tripped up by template-like content' do
            expect(subject.strip("#{text}-[7]-!")).to eq "#{text}-[7]-!"
          end

          it 'is not tripped up by default template-like content' do
            expect(subject.strip("#{text} (7)")).to eq "#{text} (7)"
          end
        end
      end

      describe '#to_s' do
        it 'works out fine with the default template' do
          expect(subject.to_s).to eq ' (88)'
        end

        context 'overridden template' do
          let(:subject) { described_class.new(index, template: custom_template) }

          it 'works out fine with the overridden template' do
            expect(subject.to_s).to eq '-[88]-'
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nameq-0.0.1 spec/support/suffix_spec.rb