Sha256: 578abbff8315c3cbba331dfc47a5e9f411d0cac3b9350997a6a2249ad2a8bec0

Contents?: true

Size: 1005 Bytes

Versions: 42

Compression:

Stored size: 1005 Bytes

Contents

describe Ppl::Command::Add do

  before(:each) do
    @command = Ppl::Command::Add.new
    @input   = Ppl::Application::Input.new
    @storage = double(Ppl::Adapter::Storage)

    @command.storage = @storage
  end

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

  describe "#execute" do

    it "should raise a Ppl::Error::IncorrectUsage if no id is given" do
      expect{@command.execute(@input, nil)}.to raise_error(Ppl::Error::IncorrectUsage)
    end

    it "should raise a Ppl::Error::IncorrectUsage if no name is given" do
      @input.arguments = ["some_id"]
      expect{@command.execute(@input, nil)}.to raise_error(Ppl::Error::IncorrectUsage)
    end

    it "should save a new contact" do
      @storage.should_receive(:save_contact) do |contact|
        contact.id.should eq "john"
        contact.name.should eq "John Doe"
      end
      @input.arguments = ["john", "John Doe"]
      @command.execute(@input, nil)
    end

  end

end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
ppl-2.0.0 spec/ppl/command/add_spec.rb
ppl-1.25.0 spec/ppl/command/add_spec.rb
ppl-1.24.0 spec/ppl/command/add_spec.rb
ppl-1.23.0 spec/ppl/command/add_spec.rb
ppl-1.22.2 spec/ppl/command/add_spec.rb
ppl-1.22.1 spec/ppl/command/add_spec.rb
ppl-1.22.0 spec/ppl/command/add_spec.rb
ppl-1.21.0 spec/ppl/command/add_spec.rb
ppl-1.20.0 spec/ppl/command/add_spec.rb
ppl-1.19.0 spec/ppl/command/add_spec.rb
ppl-1.18.0 spec/ppl/command/add_spec.rb
ppl-1.17.2 spec/ppl/command/add_spec.rb
ppl-1.17.1 spec/ppl/command/add_spec.rb
ppl-1.17.0 spec/ppl/command/add_spec.rb
ppl-1.16.0 spec/ppl/command/add_spec.rb
ppl-1.15.1 spec/ppl/command/add_spec.rb
ppl-1.15.0 spec/ppl/command/add_spec.rb
ppl-1.14.1 spec/ppl/command/add_spec.rb
ppl-1.14.0 spec/ppl/command/add_spec.rb
ppl-1.13.0 spec/ppl/command/add_spec.rb