finish updating cucumber scenario's to the stricter capybara

This commit is contained in:
Reinier Balt 2013-01-01 17:38:59 +01:00
parent ee3f8a3f8b
commit 796685072d
11 changed files with 55 additions and 34 deletions

View file

@ -62,7 +62,7 @@ Feature: Manage the list of contexts
Then I should see that a context named "@ipad" is not present
And I should see that the context container for hidden contexts is not present
@javascript
@javascript
Scenario: Delete context from context page right after an edit
Given I have a context called "@computer"
When I go to the contexts page
@ -71,7 +71,7 @@ Feature: Manage the list of contexts
Then he should see that a context named "@laptop" is not present
And the badge should show 0
@javascript
@javascript
Scenario: Edit context from context twice
Given I have a context called "@computer"
When I go to the contexts page
@ -82,7 +82,7 @@ Feature: Manage the list of contexts
And he should see that a context named "@ipad" is present
And the badge should show 1
@javascript
@javascript
Scenario Outline: Add a new context with state
Given I have the following contexts
| context | hide |

View file

@ -11,14 +11,14 @@ Feature: Show the actions that are tagged on the mobile page
And I have logged in as "testuser" with password "secret"
And I have a context called "@mobile"
And I have a project "my project" that has the following todos
| context | description | tags |
| context | description | tags |
| @mobile | first action | test, bla |
| @mobile | second action | bla |
Scenario: I can follow the tag of a action to see all actions belonging to that todo
When I go to the home page
And I follow "test"
And I follow the tag "test"
Then the badge should show 1
When I go to the home page
And I follow "bla"
And I follow the tag "bla"
Then the badge should show 2

View file

@ -35,14 +35,14 @@ Feature: View, add, remove notes
And I delete the first note
Then the badge should show 1
@javascript
@javascript
Scenario: Edit a note
Given I have a project "Pass Final Exam" with 2 notes
When I go to the notes page
And I edit the first note to "edited note"
Then I should see "edited note"
@javascript
@javascript
Scenario: Toggle all notes
Given I have a context called "@pc"
And I have a project "take notes" that has the following todos

View file

@ -105,7 +105,7 @@ Feature: Manage the list of projects
And I have a project "very busy" with 10 todos
When I go to the projects page
Then the project "test" should be above the project "very busy"
When I sort the list by number of tasks
When I sort the active list by number of tasks
Then the project "very busy" should be above the project "test"
@javascript

View file

@ -14,9 +14,11 @@ end
When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name|
find("a#link_edit_context_#{@context.id}").click
page.should have_css("button#submit_context_#{@context.id}", :visible=>true)
fill_in "context_name", :with => new_name
click_button "submit_context_#{@context.id}"
within "div.edit-form" do
fill_in "context_name", :with => new_name
click_button "submit_context_#{@context.id}"
end
# wait for the form to go away
page.should have_css("a#link_edit_context_#{@context.id}", :visible=> true)

View file

@ -0,0 +1,4 @@
When /^I follow the tag "(.*?)"$/ do |tag_name|
# there could be more than one tag on the page, so use the first
all(:xpath, "//span[@class='tag #{tag_name}']/a")[0].click
end

View file

@ -4,7 +4,7 @@ When /^I add note "([^\"]*)" from the "([^\"]*)" project page$/ do |note, projec
end
When /^I delete the first note$/ do
title = page.find("div.container h2").text
title = page.all("div.container h2").first.text
id = title.split(' ').last
handle_js_confirm do
@ -20,12 +20,14 @@ When /^I click the icon next to the note$/ do
end
When /^I edit the first note to "([^"]*)"$/ do |note_body|
title = page.find("div.container h2").text
title = page.all("div.container h2").first.text
id = title.split(' ').last
click_link "link_edit_note_#{id}"
fill_in "note[body]", :with => note_body
click_button "submit_note_#{id}"
within "form#edit_form_note_#{id}" do
fill_in "note[body]", :with => note_body
click_button "submit_note_#{id}"
end
end
When /^I toggle the note of "([^"]*)"$/ do |todo_description|
@ -79,5 +81,5 @@ Then /^I should not see the note "([^"]*)"$/ do |note_content|
end
Then /^I should see the note "([^"]*)"$/ do |note_content|
page.find("div", :text => note_content).should be_visible
page.all("div", :text => note_content).first.should be_visible
end

View file

@ -35,15 +35,19 @@ end
When /^I sort the active list alphabetically$/ do
handle_js_confirm do
click_link "Alphabetically"
within "div#list-active-projects-container" do
click_link "Alphabetically"
end
wait_for_ajax
end
get_confirm_text.should == "Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order."
end
When /^I sort the list by number of tasks$/ do
When /^I sort the active list by number of tasks$/ do
handle_js_confirm do
click_link "By number of tasks"
within "div#list-active-projects-container" do
click_link "By number of tasks"
end
wait_for_ajax
end
get_confirm_text.should == "Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order."

View file

@ -97,7 +97,9 @@ When /^I try to edit the description of "([^"]*)" to "([^"]*)"$/ do |action_desc
todo.should_not be_nil
open_edit_form_for(todo)
fill_in "todo_description", :with => new_description
within "form.edit_todo_form" do
fill_in "todo_description", :with => new_description
end
submit_button_xpath = "//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']"
page.find(:xpath, submit_button_xpath).click
wait_for_ajax

View file

@ -22,16 +22,15 @@ module TracksStepHelper
end
def open_edit_form_for(todo)
within "div#line_todo_#{todo.id}" do
find("a#icon_edit_todo_#{todo.id}").click
end
# on calendar page there can be more than 1 occurance of a todo, so we select the first here
all(:css, "div#line_todo_#{todo.id} a#icon_edit_todo_#{todo.id}")[0].click
wait_for_ajax
wait_for_animations_to_end
end
def submit_form(form_css, button_name)
def submit_form(form_xpath, button_name)
handle_js_confirm do
within(form_css) do
within(:xpath, form_xpath) do
click_button(button_name)
end
wait_for_ajax
@ -40,23 +39,23 @@ module TracksStepHelper
end
def submit_multiple_next_action_form
submit_form("form#todo-form-multi-new-action", "todo_multi_new_action_submit")
submit_form("//form[@id='todo-form-multi-new-action']", "todo_multi_new_action_submit")
end
def submit_next_action_form
submit_form("#todo-form-new-action", "todo_new_action_submit")
submit_form("//form[@id='todo-form-new-action']", "todo_new_action_submit")
end
def submit_new_context_form
submit_form("form#context-form", "context_new_submit")
submit_form("//form[@id='context-form']", "context_new_submit")
end
def submit_new_project_form
submit_form("form#project_form", "project_new_project_submit")
submit_form("//form[@id='project_form']", "project_new_project_submit")
end
def submit_edit_todo_form (todo)
submit_form("div#edit_todo_#{todo.id}", "submit_todo_#{todo.id}")
submit_form("//div[@id='edit_todo_#{todo.id}']", "submit_todo_#{todo.id}")
wait_for_todo_form_to_go_away(todo)
end
@ -81,7 +80,9 @@ module TracksStepHelper
def edit_project(project)
open_project_edit_form(project)
yield
within "form#edit_form_project_#{project.id}" do
yield
end
submit_project_edit_form(project)
wait_for_ajax

View file

@ -10,10 +10,16 @@ class DoneTodos
end
def self.done_this_week(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
todos.completed_before(Time.zone.now.beginning_of_day).completed_after(Time.zone.now.beginning_of_week).all(includes)
done_between(todos, Time.zone.now.beginning_of_day, Time.zone.now.beginning_of_week)
end
def self.done_this_month(todos, includes = {:include => Todo::DEFAULT_INCLUDES})
todos.completed_before(Time.zone.now.beginning_of_week).completed_after(Time.zone.now.beginning_of_month).all(includes)
done_between(todos, includes, Time.zone.now.beginning_of_week, Time.zone.now.beginning_of_month)
end
private
def self.done_between(todos, includes, start_date, end_date)
todos.completed_before(start_date).completed_after(end_date).all(includes)
end
end