From 9c82e9c974ddad86e5ae03783166ba1ee72d64d4 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Fri, 16 Jul 2010 14:41:04 +0200 Subject: [PATCH] DRY things up a bit --- features/step_definitions/todo_steps.rb | 10 ++++------ features/support/world.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 features/support/world.rb diff --git a/features/step_definitions/todo_steps.rb b/features/step_definitions/todo_steps.rb index d5c8020c..b36a15f8 100644 --- a/features/step_definitions/todo_steps.rb +++ b/features/step_definitions/todo_steps.rb @@ -68,12 +68,12 @@ end When /^I submit a new action with description "([^"]*)"$/ do |description| fill_in "todo[description]", :with => description - selenium.click("xpath=//form[@id='todo-form-new-action']//button[@id='todo_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + submit_next_action_form end When /^I submit multiple actions with using$/ do |multiple_actions| fill_in "todo[multiple_todos]", :with => multiple_actions - selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + submit_multiple_next_action_form end When /^I fill the multiple actions form with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$/ do |descriptions, project_name, context_name, tags| @@ -85,16 +85,14 @@ end When /^I submit the new multiple actions form with "([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$/ do |descriptions, project_name, context_name, tags| When "I fill the multiple actions form with \"#{descriptions}\", \"#{project_name}\", \"#{context_name}\", \"#{tags}\"" - selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + submit_multiple_next_action_form end When /^I submit the new multiple actions form with$/ do |multi_line_descriptions| fill_in "todo[multiple_todos]", :with => multi_line_descriptions - selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + submit_multiple_next_action_form end - - Then /^the dependencies of "(.*)" should include "(.*)"$/ do |child_name, parent_name| parent = @current_user.todos.find_by_description(parent_name) parent.should_not be_nil diff --git a/features/support/world.rb b/features/support/world.rb new file mode 100644 index 00000000..7bdf463a --- /dev/null +++ b/features/support/world.rb @@ -0,0 +1,12 @@ +module TracksStepHelper + def submit_multiple_next_action_form + selenium.click("xpath=//form[@id='todo-form-multi-new-action']//button[@id='todo_multi_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + end + + def submit_next_action_form + selenium.click("xpath=//form[@id='todo-form-new-action']//button[@id='todo_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery) + end + +end + +World(TracksStepHelper) \ No newline at end of file