Sha256: 98354cea680351cd7075c14d299bc0f9f2cb9b7020f0327a8b7f0d43241fc4a1

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require 'helper'

describe TomatoHarvest::CLI do

  describe 'add' do

    it 'adds a task to the list' do
      out = capture_io { TomatoHarvest::CLI.start ['add', 'foo'] }.join ''
      expect(out).to match(/foo added with id 1/)
    end

  end

  describe 'list' do

    it 'shows a table of the tasks' do
      TomatoHarvest::CLI.start ['add', 'foo']
      TomatoHarvest::CLI.start ['add', 'bar']
      out = capture_io { TomatoHarvest::CLI.start ['list'] }.join ''
      expect(out).to match(/id  name\n\s*1  foo\n\s*2  bar/)
    end

  end

  describe 'start' do
    before do
      TomatoHarvest::CLI.start ['add', 'foo']
    end

    it 'starts the timer' do
      out = capture_io { TomatoHarvest::CLI.start ['start', 1] }.join ''
      expect(out).to match(/Timer started for foo/)
    end

    it 'starts the timer with specified length' do
      out = capture_io { TomatoHarvest::CLI.start ['start', 1, 15] }.join ''
      expect(out).to match(/Timer started for foo/)
    end

    context 'when config has valid harvest options' do

      before do
        options = {
          project:  'Pomodoro',
          type:     'Ruby Development',
          domain:   'domain',
          username: 'user',
          password: 'password'
        }

        path = TomatoHarvest::Config::CONFIG_PATH
        File.open(path, 'w') do |file|
          YAML::dump(options, file)
        end
      end

      it 'starts the timer with specified length' do
        out = capture_io { TomatoHarvest::CLI.start ['start', 1] }.join ''
        expect(out).to match(/Timer started for foo/)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tomatoharvest-0.0.1 spec/lib/tomatoharvest/cli_spec.rb