Sha256: 14a74e53bd141384f55ead7cfa3b30aa88474109bb3db563eaf6673c4552e402

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path('spec_helper', File.dirname(__FILE__))

module Imb

  describe BarPosition do

    describe '#map' do

      let(:characters) {mock 'array of characters'}
      let(:descender_character_position) {mock CharacterPosition}
      let(:ascender_character_position) {mock CharacterPosition}
      let(:bar_position) do
        BarPosition.new(descender_character_position,
                        ascender_character_position)
      end

      before(:each) do
        descender_character_position.stub(:extract_bit_from_characters)\
        .with(characters).and_return(descender_bit)
        ascender_character_position.stub(:extract_bit_from_characters)\
        .with(characters).and_return(ascender_bit)
      end

      context 'without ascender, without descender' do
        let(:ascender_bit) {0}
        let(:descender_bit) {0}
        specify {bar_position.map(characters).should == 0}
      end

      context 'without ascender, with descender' do
        let(:ascender_bit) {0}
        let(:descender_bit) {1}
        specify {bar_position.map(characters).should == 1}
      end

      context 'with ascender, without descender' do
        let(:ascender_bit) {1}
        let(:descender_bit) {0}
        specify {bar_position.map(characters).should == 2}
      end

      context 'with ascender, with descender' do
        let(:ascender_bit) {1}
        let(:descender_bit) {1}
        specify {bar_position.map(characters).should == 3}
      end

    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
USPS-intelligent-barcode-0.2.3 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.2.2 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.2.1 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.2.0 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.1.2 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.1.1 spec/BarPosition_spec.rb
USPS-intelligent-barcode-0.1.0 spec/BarPosition_spec.rb