implement new scenarios that were pending from the selenium-on-rails removal and fix a bug it uncovered

This commit is contained in:
Reinier Balt 2011-09-14 20:50:21 +02:00
parent 9eca1557fb
commit 2563532022
6 changed files with 103 additions and 23 deletions

View file

@ -1,14 +1,24 @@
Given /^I have a project "([^\"]*)" with (.*) todos$/ do |project_name, num_todos|
Given /^I have a project "([^\"]*)" with ([0-9]+) 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)
# acts_as_list adds at top by default, but that is counter-intuitive when reading scenario's, so reverse this
@project.move_to_bottom
@todos=[]
1.upto num_todos.to_i do |i|
@current_user.todos.create!(
todo = @current_user.todos.create!(
:project_id => @project.id,
:context_id => @context.id,
:description => "todo #{i}")
@todos << todo
end
end
Given /^I have a project "([^\"]*)" with ([0-9]+) deferred todos$/ do |project_name, num_todos|
Given "I have a project \"#{project_name}\" with #{num_todos} todos"
@todos.each do |todo|
todo.show_from = Time.zone.now + 1.week
todo.save!
end
end
@ -130,6 +140,44 @@ When /^I try to edit the project name to "([^\"]*)"$/ do |new_title|
:timeout => 5
end
When /^I edit the default context to "([^"]*)"$/ do |default_context|
click_link "link_edit_project_#{@project.id}"
wait_for do
selenium.is_element_present("submit_project_#{@project.id}")
end
fill_in "project[default_context_name]", :with => default_context
selenium.click "submit_project_#{@project.id}",
:wait_for => :text,
:text => "Project saved",
:timeout => 5
wait_for :timeout => 5 do
!selenium.is_element_present("submit_project_#{@project.id}")
end
end
Then /^I edit the default tags to "([^"]*)"$/ do |default_tags|
click_link "link_edit_project_#{@project.id}"
wait_for do
selenium.is_element_present("submit_project_#{@project.id}")
end
fill_in "project[default_tags]", :with => default_tags
selenium.click "submit_project_#{@project.id}",
:wait_for => :text,
:text => "Project saved",
:timeout => 5
wait_for :timeout => 5 do
!selenium.is_element_present("submit_project_#{@project.id}")
end
end
When /^I edit the project name of "([^"]*)" to "([^"]*)"$/ do |project_current_name, project_new_name|
@project = @current_user.projects.find_by_name(project_current_name)
@project.should_not be_nil
@ -225,7 +273,9 @@ Then /^I should see the italic text "([^\"]*)" in the project description$/ do |
end
Then /^the project title should be "(.*)"$/ do |title|
selenium.get_text("css=h2#project_name").should == title
wait_for :timeout => 2 do
selenium.get_text("css=h2#project_name") == title
end
end
Then /^I should see the project name is "([^"]*)"$/ do |project_name|

View file

@ -139,6 +139,10 @@ When /^I remove the show from date from "([^"]*)"$/ do |action_description|
submit_edit_todo_form(todo)
end
When /^I clear the show from date of "([^"]*)"$/ do |action_description|
When "I remove the show from date from \"#{action_description}\""
end
When /^I defer "([^"]*)" for 1 day$/ do |action_description|
todo = @current_user.todos.find_by_description(action_description)
todo.should_not be_nil

View file

@ -96,7 +96,6 @@ Then /^the selected context should be "([^"]*)"$/ do |content|
field_labeled("Context").element.search(".//option[@selected = 'selected']").inner_html.should =~ /#{content}/
end
Then /^I should see the page selector$/ do
page_selector_xpath = ".//a[@class='next_page']"
response.body.should have_xpath(page_selector_xpath)
@ -110,3 +109,30 @@ Then /^the page should be "([^"]*)"$/ do |page_number|
end
page_number_found.should == page_number.to_i
end
Then /^the project field of the new todo form should contain "([^"]*)"$/ do |project_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_project_name']"
project_name.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the default context of the new todo form should be "([^"]*)"$/ do |context_name|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_context_name']"
context_name.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the tag field in the new todo form should be empty$/ do
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_tag_list']"
assert response.selenium.get_value("xpath=#{xpath}").blank?
end
Then /^the tag field in the new todo form should be "([^"]*)"$/ do |tag_list|
xpath= "//form[@id='todo-form-new-action']/input[@id='todo_tag_list']"
tag_list.should == response.selenium.get_value("xpath=#{xpath}")
end
Then /^the tags of "([^"]*)" should be "([^"]*)"$/ do |todo_description, tag_list|
todo = @current_user.todos.find_by_description(todo_description)
todo.should_not be_nil
todo.tag_list.should == tag_list
end