Skip to content

Commit

Permalink
Add trunk code specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jun 8, 2021
1 parent 06d9cdd commit 4152f17
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions spec/lib/phony/trunk_code_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
require 'spec_helper'

describe Phony::TrunkCode do

describe '#format' do
it 'is correct' do
code = described_class.new('0')
expect(code.format('%s %s')).to eq '0'
end
it 'is correct' do
code = described_class.new('0', format: true)
expect(code.format('%s %s')).to eq '0'
end
it 'is correct' do
code = described_class.new('0', format: false)
expect(code.format('%s %s')).to eq nil
end
it 'is correct' do
code = described_class.new('06')
expect(code.format('%s %s')).to eq '06'
end
it 'is correct' do
code = described_class.new('06', format: true)
expect(code.format('%s %s')).to eq '06'
end
it 'is correct' do
code = described_class.new('06', format: false)
expect(code.format('%s %s')).to eq nil
end
end

describe '#normalize' do
it 'is correct' do
code = described_class.new('0')
expect(code.normalize('0123')).to eq '0123'
end
it 'is correct' do
code = described_class.new('0', normalize: true)
expect(code.normalize('0123')).to eq '0123'
end
it 'is correct' do
code = described_class.new('0', normalize: false)
expect(code.normalize('0123')).to eq '0123'
end
it 'is correct' do
code = described_class.new('06')
expect(code.normalize('06123')).to eq '06123'
end
it 'is correct' do
code = described_class.new('06', normalize: true)
expect(code.normalize('06123')).to eq '06123'
end
it 'is correct' do
code = described_class.new('06', normalize: false)
expect(code.normalize('0123')).to eq '0123'
end
end

describe '#split' do
it 'is correct' do
code = described_class.new('0')
expect(code.split('0123')).to eq [code, '0123']
end
it 'is correct' do
code = described_class.new('0', split: true)
expect(code.split('0123')).to eq [code, '123']
end
it 'is correct' do
code = described_class.new('0', split: false)
expect(code.split('0123')).to eq [code, '0123']
end
it 'is correct' do
code = described_class.new('06')
expect(code.split('06123')).to eq [code, '06123']
end
it 'is correct' do
code = described_class.new('06', split: true)
expect(code.split('06123')).to eq [code, '123']
end
it 'is correct' do
code = described_class.new('06', split: false)
expect(code.split('06123')).to eq [code, '06123']
end
end
end

0 comments on commit 4152f17

Please sign in to comment.