spec/lib/tomatoharvest/timer_spec.rb in tomatoharvest-0.0.1 vs spec/lib/tomatoharvest/timer_spec.rb in tomatoharvest-0.1.0
- old
+ new
@@ -4,14 +4,18 @@
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 = TomatoHarvest::List.new
list.add(task)
- list.save
+ list.save!
end
def stub_notifier(minutes)
message = "Pomodoro started for #{minutes} minutes"
options = {:title=>"TomatoHarvest", :subtitle=> 'foo'}
@@ -21,26 +25,26 @@
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(task.id, minutes: 15)
+ TomatoHarvest::Timer.start(list, task.id, minutes: 15)
- reloaded_task = TomatoHarvest::List.find(task.id)
+ 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(task.id, minutes: 20)
- TomatoHarvest::Timer.start(task.id, minutes: 20)
- reloaded_task = TomatoHarvest::List.find(task.id)
+ 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
- entry.should_receive(:log)
- TomatoHarvest::Timer.start(task.id, time_entry: entry, minutes: 25)
+ expect(entry).to receive(:log)
+ TomatoHarvest::Timer.start(list, task.id, time_entry: entry, minutes: 25)
end
end
end