Sha256: d52de21a11b1510c74cc3f4bc1ba575ba3d7cfe99a055fad1647c7b3ae4391a5

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'helper'

describe TomatoHarvest::Timer do

  describe '.start' do

    let(:task) { TomatoHarvest::Task.new('foo') }

    let(:list) do
      path = TomatoHarvest::ListLoader.global_path
      TomatoHarvest::List.new(path)
    end

    before do
      list.add(task)
      list.save!
    end

    def stub_notifier(minutes)
      message = "Pomodoro started for #{minutes} minutes"
      options = {:title=>"TomatoHarvest", :subtitle=> 'foo'}
      TerminalNotifier.should_receive(:notify).with(message, options)

      message = "Pomodoro finished"
      options = {:title=>"TomatoHarvest", :subtitle=> 'Pomodoro finished!'}
      TerminalNotifier.should_receive(:notify).with(message, options)
    end

    it 'can run for a custom length' do
      TomatoHarvest::Timer.start(list, task.id, minutes: 15)

      reloaded_task = list.find(task.id)
      expect(reloaded_task.logged_minutes).to eql(15.0)
    end

    it 'can be run twice' do
      TomatoHarvest::Timer.start(list, task.id, minutes: 20)
      TomatoHarvest::Timer.start(list, task.id, minutes: 20)
      reloaded_task = list.find(task.id)
      expect(reloaded_task.logged_minutes).to eql(40.0)
    end

    it 'logs a time entry if passed in' do
      entry = double
      expect(entry).to receive(:log)
      TomatoHarvest::Timer.start(list, task.id, time_entry: entry, minutes: 25)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tomatoharvest-0.1.1 spec/lib/tomatoharvest/timer_spec.rb
tomatoharvest-0.1.0 spec/lib/tomatoharvest/timer_spec.rb