add some pending cucumber scenarios and fix a small bug it uncovered

This commit is contained in:
Reinier Balt 2011-08-11 17:13:01 +02:00
parent 30c578f93a
commit f544c80fbc
15 changed files with 290 additions and 65 deletions

View file

@ -51,7 +51,7 @@ Then /^I should not see "([^"]*)" in the context container for "([^"]*)"$/ do |t
todo.should_not be_nil
xpath = "xpath=//div[@id=\"c#{context.id}\"]//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
# give jquery some time to finish
wait_for :timeout_in_seconds => 5 do
@ -82,6 +82,23 @@ Then /^I should see "([^"]*)" in the action container$/ do |todo_description|
end
end
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
project = @current_user.projects.find_by_name(project_name)
project.should_not be_nil
xpath = "//div[@id='p#{todo.project.id}items']//div[@id='line_todo_#{todo.id}']"
if selenium.is_element_present(xpath)
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end
end
end
Then /^I should see "([^"]*)" in the completed container$/ do |todo_description|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
@ -130,7 +147,7 @@ end
Then /^I should see "([^"]*)" in the active recurring todos container$/ do |repeat_pattern|
repeat = @current_user.recurring_todos.find_by_description(repeat_pattern)
unless repeat.nil?
xpath = "//div[@id='active_recurring_todos_container']//div[@id='recurring_todo_#{repeat.id}']"
selenium.wait_for_element("xpath=#{xpath}", :timeout_in_seconds => 5)

View file

@ -65,7 +65,7 @@ When /^I edit the dependency of "([^"]*)" to remove "([^"]*)" as predecessor$/ d
wait_for :timeout=>5 do
!selenium.is_element_present(delete_dep_button)
end
submit_edit_todo_form(todo)
# note that animations will be running after the ajax is completed
end
@ -109,6 +109,7 @@ Then /^I should not see "([^"]*)" within the dependencies of "([^"]*)"$/ do |suc
successor.should_not be_nil
# let selenium look for the presence of the successor
xpath = "xpath=//div[@id='line_todo_#{todo.id}']//div[@id='successor_line_todo_#{successor.id}']//span"
wait_for :timeout => 5 do
!selenium.is_element_present(xpath)
end

View file

@ -1,11 +1,11 @@
Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos|
context = @current_user.contexts.find_or_create_by_name("Context A")
project = @current_user.projects.create!(:name => project_name)
@context = @current_user.contexts.find_or_create_by_name("Context A")
@project = @current_user.projects.create!(:name => project_name)
1.upto num_todos.to_i do |i|
@current_user.todos.create!(
:project_id => project.id,
:context_id => context.id,
:description => "Todo #{i}")
:project_id => @project.id,
:context_id => @context.id,
:description => "todo #{i}")
end
end
@ -71,7 +71,7 @@ When /^I edit the project name to "([^\"]*)"$/ do |new_title|
wait_for do
selenium.is_element_present("submit_project_#{@project.id}")
end
fill_in "project[name]", :with => new_title
selenium.click "submit_project_#{@project.id}",
@ -180,7 +180,7 @@ Then /^I should see the bold text "([^\"]*)" in the project description$/ do |bo
response.should have_xpath(xpath)
bold_text = response.selenium.get_text("xpath=#{xpath}")
bold_text.should =~ /#{bold}/
end

View file

@ -3,6 +3,30 @@ When /^I submit a new action with description "([^"]*)"$/ do |description|
submit_next_action_form
end
When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description|
predecessor = @current_user.todos.find_by_description(predecessor_description)
predecessor.should_not be_nil
fill_in "todo[description]", :with => todo_description
input = "xpath=//form[@id='todo-form-new-action']//input[@id='predecessor_input']"
selenium.focus(input)
selenium.type_keys input, predecessor_description
# wait for auto complete
autocomplete = "xpath=//a[@id='ui-active-menuitem']"
selenium.wait_for_element(autocomplete, :timeout_in_seconds => 5)
# click first line
first_elem = "xpath=//ul/li[1]/a[@id='ui-active-menuitem']"
selenium.click(first_elem)
new_dependency_line = "xpath=//li[@id='pred_#{predecessor.id}']"
selenium.wait_for_element(new_dependency_line, :timeout_in_seconds => 5)
submit_next_action_form
end
When /^I submit a new action with description "([^"]*)" and the tags "([^"]*)" in the context "([^"]*)"$/ do |description, tags, context_name|
fill_in "todo[description]", :with => description
fill_in "tag_list", :with => tags

View file

@ -7,8 +7,12 @@ When /I change the (.*) field of "([^\"]*)" to "([^\"]*)"$/ do |field_name, todo
submit_edit_todo_form(todo)
end
When /^I edit the context of "([^"]*)" to "([^"]*)"$/ do |context_old_name, context_new_name|
When "I change the context_name field of \"#{context_old_name}\" to \"#{context_new_name}\""
When /^I edit the context of "([^"]*)" to "([^"]*)"$/ do |todo_name, context_new_name|
When "I change the context_name field of \"#{todo_name}\" to \"#{context_new_name}\""
end
When /^I edit the project of "([^"]*)" to "([^"]*)"$/ do |todo_name, project_new_name|
When "I change the project_name field of \"#{todo_name}\" to \"#{project_new_name}\""
end
When /^I edit the description of "([^"]*)" to "([^"]*)"$/ do |action_description, new_description|
@ -46,9 +50,9 @@ end
When /^I remove the show from date from "([^"]*)"$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil
open_edit_form_for(todo)
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='show_from_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
submit_edit_todo_form(todo)
end

View file

@ -4,7 +4,7 @@ end
Given /^I have a todo "([^"]*)" in the context "([^"]*)"$/ do |description, context_name|
context = @current_user.contexts.find_or_create(:name => context_name)
@current_user.todos.create!(:context_id => context.id, :description => description)
@todo = @current_user.todos.create!(:context_id => context.id, :description => description)
end
Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/ do |description, context_name|
@ -14,6 +14,22 @@ Given /^I have a todo "([^"]*)" in the context "([^"]*)" which is due tomorrow$/
@todo.save!
end
Given /^I have (\d+) todos in project "([^"]*)" in context "([^"]*)" with tags "([^"]*)"$/ do |number_of_todos, project_name, context_name, tag_names|
@context = @current_user.contexts.find_by_name(context_name)
@context.should_not be_nil
@project = @current_user.projects.find_by_name(project_name)
@project.should_not be_nil
@todos = []
number_of_todos.to_i.downto 1 do |i|
todo = @current_user.todos.create!(:context_id => @context.id, :description => "todo #{i}", :project_id => @project.id)
todo.tag_with(tag_names)
todo.save!
@todos << todo
end
end
Given /^I have a todo "([^"]*)"$/ do |description|
Given "I have a todo \"#{description}\" in the context \"Context A\""
end
@ -133,6 +149,26 @@ Given /^I have a project "([^"]*)" that has the following todos$/ do |project_na
end
end
Given /^I have a project "([^"]*)" that has the following deferred todos$/ do |project_name, todos|
Given "I have a project called \"#{project_name}\""
@project.should_not be_nil
todos.hashes.each do |todo|
context = @current_user.contexts.find_by_name(todo[:context])
context.should_not be_nil
new_todo = @current_user.todos.create!(
:description => todo[:description],
:context_id => context.id,
:project_id=>@project.id,
:show_from=>Time.zone.now+1.week)
unless todo[:tags].nil?
new_todo.tag_with(todo[:tags])
end
unless todo[:completed].nil?
new_todo.complete! if todo[:completed] == 'yes'
end
end
end
When /^I mark "([^"]*)" as complete$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil