Sha256: ace1a2a254bfd275b46ae4b32f7b092553b56e08de5bf88243850b58f9ea0cea

Contents?: true

Size: 945 Bytes

Versions: 27

Compression:

Stored size: 945 Bytes

Contents

describe Ppl::Format::Contact::Age do

  before(:each) do
    @format  = Ppl::Format::Contact::Age.new
    @contact = double(Ppl::Entity::Contact)
    @color   = double(Ppl::Adapter::Color)
    @format.color_adapter = @color
  end

  describe "#process" do

    it "should return an empty string if the contact lacks a birth date" do
      @color.stub(:colorize)
      @contact.should_receive(:age).and_return(nil)
      @format.process(@contact).should eq ""
    end

    it "should return the contact's age if the birthdate is known" do
      @contact.should_receive(:age).and_return(10)
      @format.process(@contact).should eq "10"
    end

    it "should colorize the string if configured to do so" do
      @contact.should_receive(:age).and_return(10)
      @format.colors = { "age" => "blue" }
      @color.should_receive(:colorize).and_return("age in blue")
      @format.process(@contact).should eq "age in blue"
    end

  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ppl-1.18.0 spec/ppl/format/contact/age_spec.rb
ppl-1.17.2 spec/ppl/format/contact/age_spec.rb
ppl-1.17.1 spec/ppl/format/contact/age_spec.rb
ppl-1.17.0 spec/ppl/format/contact/age_spec.rb
ppl-1.16.0 spec/ppl/format/contact/age_spec.rb
ppl-1.15.1 spec/ppl/format/contact/age_spec.rb
ppl-1.15.0 spec/ppl/format/contact/age_spec.rb