features/step_definitions/TimeLogger_steps.rb in TimeLogger-0.0.1 vs features/step_definitions/TimeLogger_steps.rb in TimeLogger-0.0.2

- old
+ new

@@ -1,62 +1,125 @@ \ No newline at end of file +Given /^no task is active$/ do + setup +end + +When /^I start task "(.*)"$/ do |name| + @logger.start(name) +end + +Then /^I should see "([^\"]*)"$/ do |msg| + @ui.msgs.should include(msg) +end + +Given /^an active task "([^\"]*)"$/ do |task_name| + setup + + @logger.start(task_name) +end + +Given /^an active task "([^\"]*)" I worked on for (\d+) minutes$/ do |name, minutes| + setup + + @logger.start(name) + @timer.add_minutes(minutes.to_i) +end + +Given /^an inactive task "([^\"]*)" I worked on for (\d+) minutes$/ do |name, minutes| + setup + + @logger.start(name) + @timer.add_minutes(minutes.to_i) + @logger.stop(name) +end + +When /^I do some work for (\d+) minutes$/ do |minutes| + @timer.add_minutes(minutes.to_i) +end + +When /^I stop task "([^\"]*)"$/ do |task_name| + @logger.stop(task_name) +end + +Given /^I worked on the following tasks:$/ do |table| + setup + + table.hashes.each do |hash| + name = hash["name"] + minutes = hash["minutes"].to_i + + @logger.start(name) + @timer.add_minutes(minutes) + @logger.stop(name) + end +end + +When /^I list tasks$/ do + @logger.list +end + +def setup + @ui = TimeLogger::UI.new + @timer = TimeLogger::Timer.new + @logger = TimeLogger::TimeLogger.new(@timer, @ui) +end