Sha256: 1bf5ba1f43c572ed07674b725581d2f89248506b16a517533168075570b75d0c

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

describe Ppl::Format::PostalAddress::OneLine do

  before(:each) do
    @format  = Ppl::Format::PostalAddress::OneLine.new
    @table   = double(Ppl::Format::Table)
    @address = Ppl::Entity::PostalAddress.new
  end

  describe "#process" do

    before(:each) do
      @address.id = "home"
      @address.street = "123 Happy Lane"
      @address.country = "United Kingdom"
    end

    after(:each) do
      @format.process(@address, @table)
    end

    it "inserts a blank 'star' column" do
      @table.should_receive(:add_row) { |r| r[:star].should eq " " }
    end

    it "marks preferred addresses with a star" do
      @address.preferred = true
      @table.should_receive(:add_row) { |r| r[:star].should eq "*" }
    end

    it "puts the ID in its own column" do
      @table.should_receive(:add_row) { |r| r[:address_id].should eq "home" }
    end

    it "concatenates the rest of the address in its own column" do
      @address.country = nil
      @table.should_receive(:add_row) do |row|
        row[:address_text].should eq "123 Happy Lane"
      end
    end

    it "separates address elements with commas" do
      @table.should_receive(:add_row) do |row|
        row[:address_text].should eq "123 Happy Lane, United Kingdom"
      end
    end

    it "prunes elements that are empty" do
      @address.country = ""
      @table.should_receive(:add_row) do |row|
        row[:address_text].should eq "123 Happy Lane"
      end
    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ppl-3.0.1 spec/ppl/format/postal_address/one_line_spec.rb
ppl-3.0.0 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.4.1 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.4.0 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.3.3 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.3.2 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.3.1 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.3.0 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.2.0 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.1.0 spec/ppl/format/postal_address/one_line_spec.rb
ppl-2.0.0 spec/ppl/format/postal_address/one_line_spec.rb