Sha256: cd2ef0990d350843d806ded9c527c86e4406d504c4aebd2332c26479b4ec3b6f

Contents?: true

Size: 1.54 KB

Versions: 51

Compression:

Stored size: 1.54 KB

Contents

describe Ppl::Command::Bday do

  before(:each) do
    @input   = Ppl::Application::Input.new
    @output  = Ppl::Application::Output.new(nil, nil)
    @contact = Ppl::Entity::Contact.new
    @command = Ppl::Command::Bday.new
    @storage = double(Ppl::Adapter::Storage)
    @show_format  = double(Ppl::Format::Contact)

    @command.storage = @storage
    @command.show_format  = @show_format
    @contact.id = "jim"
  end

  describe "#name" do
    it "should be 'bday'" do
      @command.name.should eq "bday"
    end
  end

  describe "#execute" do

    it "should show the contact's birthday if no date is given" do
      @storage.should_receive(:require_contact).and_return(@contact)
      @show_format.should_receive(:process).and_return("1970-01-01")
      @output.should_receive(:line).with("1970-01-01")
      @input.arguments = ["jim"]
      @command.execute(@input, @output).should eq true
    end

    it "should not output anything if there's no birthday to show" do
      @storage.should_receive(:require_contact).and_return(@contact)
      @show_format.should_receive(:process).and_return("")
      @input.arguments = ["jim"]
      @command.execute(@input, @output).should eq false
    end

    it "should change the contact's birthday if a date is given" do
      @storage.should_receive(:require_contact).and_return(@contact)
      @storage.should_receive(:save_contact) do |contact|
        contact.birthday.strftime.should eq "1980-01-01"
      end
      @input.arguments = ["jim", "1980-01-01"]
      @command.execute(@input, @output)
    end

  end

end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
ppl-1.18.0 spec/ppl/command/bday_spec.rb
ppl-1.17.2 spec/ppl/command/bday_spec.rb
ppl-1.17.1 spec/ppl/command/bday_spec.rb
ppl-1.17.0 spec/ppl/command/bday_spec.rb
ppl-1.16.0 spec/ppl/command/bday_spec.rb
ppl-1.15.1 spec/ppl/command/bday_spec.rb
ppl-1.15.0 spec/ppl/command/bday_spec.rb
ppl-1.14.1 spec/ppl/command/bday_spec.rb
ppl-1.14.0 spec/ppl/command/bday_spec.rb
ppl-1.13.0 spec/ppl/command/bday_spec.rb
ppl-1.12.0 spec/ppl/command/bday_spec.rb
ppl-1.11.0 spec/ppl/command/bday_spec.rb
ppl-1.10.0 spec/ppl/command/bday_spec.rb
ppl-1.9.0 spec/ppl/command/bday_spec.rb
ppl-1.8.0 spec/ppl/command/bday_spec.rb
ppl-1.7.0 spec/ppl/command/bday_spec.rb
ppl-1.6.0 spec/ppl/command/bday_spec.rb
ppl-1.5.3 spec/ppl/command/bday_spec.rb
ppl-1.5.2 spec/ppl/command/bday_spec.rb
ppl-1.5.1 spec/ppl/command/bday_spec.rb