diff --git a/features/show_integration_options.feature b/features/show_integration_options.feature new file mode 100644 index 00000000..c77b5562 --- /dev/null +++ b/features/show_integration_options.feature @@ -0,0 +1,38 @@ +Feature: Integrate Tracks in various ways + + In order to use tracks with other software + As a Tracks user + I want to be informed about the various ways to integrate tracks + + Background: + Given the following user record + | login | password | is_admin | + | testuser | secret | false | + And I have logged in as "testuser" with password "secret" + + Scenario: I cannot see scripts when I do not have a context + Given I have no contexts + When I go to the integrations page + Then I should see a message that you need a context to see scripts + + Scenario: I can see scripts when I have one or more contexts + Given I have a context called "@pc" + When I go to the integrations page + Then I should see scripts + + @selenium + Scenario: When I select a different context the example scripts should change accoordingly + Given I have the following contexts: + | context | + | @pc | + | @home | + | @shops | + | @boss | + When I go to the integrations page + Then I should see a script "applescript1" for "@pc" + When I select "@home" from "applescript1-contexts" + Then I should see a script "applescript1" for "@home" + When I select "@shops" from "applescript2-contexts" + Then I should see a script "applescript2" for "@shops" + When I select "@boss" from "quicksilver-contexts" + Then I should see a script "quicksilver" for "@boss" diff --git a/features/step_definitions/context_steps.rb b/features/step_definitions/context_steps.rb index fa117871..a75f780c 100644 --- a/features/step_definitions/context_steps.rb +++ b/features/step_definitions/context_steps.rb @@ -1,7 +1,18 @@ +Given /^I have no contexts$/ do + # should probably not be needed as you use this given at the start of a scenario + Context.delete_all +end + Given /^I have a context called "([^\"]*)"$/ do |context_name| @context = @current_user.contexts.create!(:name => context_name) end +Given /^I have the following contexts:$/ do |table| + table.hashes.each do |context| + Given 'I have a context called "'+context[:context]+'"' + end +end + Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions| context = @current_user.contexts.create!(:name => context_name) 1.upto number_of_actions.to_i do |i| diff --git a/features/step_definitions/integration_steps.rb b/features/step_definitions/integration_steps.rb new file mode 100644 index 00000000..10d5727d --- /dev/null +++ b/features/step_definitions/integration_steps.rb @@ -0,0 +1,23 @@ +Then /^I should see a message that you need a context to see scripts$/ do + Then 'I should see "You do not have any context yet. The script will be available after you add your first context"' +end + +Then /^I should see scripts$/ do + # check on a small snippet of the first applescript + Then 'I should see "set returnValue to call xmlrpc"' +end + +Then /^I should see a script "([^\"]*)" for "([^\"]*)"$/ do |script, context_name| + selenium.is_visible(script) + context = Context.find_by_name(context_name) + + # wait for the script to refresh + wait_for :timeout => 15 do + selenium.is_text_present("#{context.id} (* #{context_name} *)") + end + + # make sure the text is found within the textarea + script_source = selenium.get_text("//textarea[@id='#{script}']") + script_source.should =~ /#{context.id} \(\* #{context_name} \*\)/ +end + diff --git a/features/step_definitions/note_steps.rb b/features/step_definitions/note_steps.rb index 630f974d..fbc93eb7 100644 --- a/features/step_definitions/note_steps.rb +++ b/features/step_definitions/note_steps.rb @@ -62,7 +62,6 @@ Then /^the first note should disappear$/ do end end - Then /^I should see the note text$/ do Then "I should see \"after 50 characters\"" end diff --git a/features/support/paths.rb b/features/support/paths.rb index 51edcca2..19142887 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -20,6 +20,8 @@ module NavigationHelpers users_path when /the repeating todos page/ recurring_todos_path + when /the integrations page/ + integrations_path # Add more page name => path mappings here diff --git a/test/selenium/integrations/no_script_if_no_contexts.rsel b/test/selenium/integrations/no_script_if_no_contexts.rsel deleted file mode 100644 index 4da2ea76..00000000 --- a/test/selenium/integrations/no_script_if_no_contexts.rsel +++ /dev/null @@ -1,14 +0,0 @@ -setup :fixtures => :users, :clear_tables => [:projects, :contexts, :todos] -login :as => 'admin' -open "/integrations" -wait_for_element_present "no_context_msg" - -open "/contexts" -type "context_name", "my first context" -click "context_new_submit" -# wait for new context to appear before navigating away from project page to -# make sure that the changes have been saved -wait_for_text_present 'DRAG' - -open "/integrations" -wait_for_element_present "applescript1-contexts"