tracks/features/step_definitions/todo_steps.rb
Reinier Balt 43440eaf33 add cucumber for integration testing and add a feature for statistics
refactor some stuff to support testing statistisc
2009-04-13 22:26:20 +02:00

31 lines
No EOL
957 B
Ruby

Given /^I have no todos$/ do
Todo.delete_all
end
Given /^I have ([0-9]+) todos$/ do |count|
context = @current_user.contexts.create!(:name => "context A")
count.to_i.downto 1 do |i|
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
end
end
Given /^I have ([0-9]+) deferred todos$/ do |count|
context = @current_user.contexts.create!(:name => "context B")
count.to_i.downto 1 do |i|
@current_user.todos.create!(:context_id => context.id, :description => "todo #{i}", :show_from => @current_user.time + 1.week)
end
end
Given /^I have ([0-9]+) completed todos$/ do |count|
context = @current_user.contexts.create!(:name => "context C")
count.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}")
todo.complete!
end
end
Then /^I should see ([0-9]+) todos$/ do |count|
count.to_i.downto 1 do |i|
match_xpath "div["
end
end