Sha256: d8b09179381d8d86e93962886c204cba0f30e47d05b54f7823d196106ec59da2

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

describe Ppl::Format::AddressBook::OneLine do
  describe "#initialize" do
    it "should pass the colors through to the table" do
      colors = {"id" => "blue"}
      Ppl::Format::Table.should_receive(:new).with([:id, :name, :email], colors)
      format = Ppl::Format::AddressBook::OneLine.new(colors)
    end
  end
end

describe Ppl::Format::AddressBook::OneLine do

  before(:each) do
    @format       = Ppl::Format::AddressBook::OneLine.new
    @address_book = Ppl::Entity::AddressBook.new
    @contact      = Ppl::Entity::Contact.new
    @table        = double(Ppl::Format::Table)

    @contact.id = "test"
    @format.table = @table

    @address_book.contacts.push(@contact)
  end

  describe "#process" do

    it "should at least show the contact's id" do
      @table.should_receive(:add_row).with({
        :id    => "test:",
        :name  => nil,
        :email => nil,
      })
      @format.process(@address_book)
    end

    it "should show all the info if it's available" do
      @contact.name = "John Doe"
      @contact.email_addresses << Ppl::Entity::EmailAddress.new("jdoe@example.org")
      @table.should_receive(:add_row).with({
        :id    => "test:",
        :name  => "John Doe",
        :email => "<jdoe@example.org>",
      })
      @format.process(@address_book)
    end

    it "should show all the info if it's available" do
      @contact.email_addresses << Ppl::Entity::EmailAddress.new("jdoe@example.org")
      @contact.email_addresses << Ppl::Entity::EmailAddress.new("fred@testtest.es")
      @contact.email_addresses[1].preferred = true
      @table.should_receive(:add_row) do |row|
        row[:email].should eq "<fred@testtest.es>"
      end
      @format.process(@address_book)
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

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