diff --git a/tracks/README_DEVELOPERS b/tracks/README_DEVELOPERS index 5849fdc0..2005ae3e 100644 --- a/tracks/README_DEVELOPERS +++ b/tracks/README_DEVELOPERS @@ -1,3 +1,15 @@ +1. SQLITE3 FOR TESTING + +By default, tests are configured to run using sqlite3 in memory mode to increase speed. You will need the sqlite3-ruby gem for this. + +To avoid showing the migrations as tests are run, add the following to your database.yml below 'database: ":memory:"': + + verbosity: quiet + +If you want to run tests using another database, that's fine, too. Just change your database.yml accordingly. + +2. SELENIUM TESTS + To run selenium tests, start Tracks in test mode using script/server -e test diff --git a/tracks/test/selenium/home/create_first_todo.rsel b/tracks/test/selenium/home/create_first_todo.rsel index 6647e26d..53f57824 100644 --- a/tracks/test/selenium/home/create_first_todo.rsel +++ b/tracks/test/selenium/home/create_first_todo.rsel @@ -1,9 +1,8 @@ setup :fixtures => :users, :clear_tables => [:projects, :contexts, :todos] login :as => 'admin' open "/" -store_context_count 'initial_context_count' -type "todo_description", "a new action" -type "todo_context_name", "Brand new context" -click "css=#todo-form-new-action .submit_box button" -store_eval "${initial_context_count} + 1", 'expected_context_count' -wait_for_context_count "${expected_context_count}" \ No newline at end of file +assert_context_count_incremented do + type "todo_description", "a new action" + type "todo_context_name", "Brand new context" + click "css=#todo-form-new-action .submit_box button" +end \ No newline at end of file diff --git a/tracks/test/selenium/home/create_new_todo_with_new_context.rsel b/tracks/test/selenium/home/create_new_todo_with_new_context.rsel index d8e84197..658922e4 100644 --- a/tracks/test/selenium/home/create_new_todo_with_new_context.rsel +++ b/tracks/test/selenium/home/create_new_todo_with_new_context.rsel @@ -1,9 +1,8 @@ setup :fixtures => :all login :as => 'admin' open "/" -store_context_count 'initial_context_count' -type "todo_description", "a new action" -type "todo_context_name", "Brand new context" -click "css=#todo-form-new-action .submit_box button" -store_eval "${initial_context_count} + 1", 'expected_context_count' -wait_for_context_count "${expected_context_count}" +assert_context_count_incremented do + type "todo_description", "a new action" + type "todo_context_name", "Brand new context" + click "css=#todo-form-new-action .submit_box button" +end \ No newline at end of file diff --git a/tracks/test/selenium_helper.rb b/tracks/test/selenium_helper.rb index 8549223a..5df487e2 100644 --- a/tracks/test/selenium_helper.rb +++ b/tracks/test/selenium_helper.rb @@ -22,7 +22,8 @@ end # For each +store_foo+ there's +assert_foo+, +assert_not_foo+, +verify_foo+, # +verify_not_foo+, +wait_for_foo+, +wait_for_not_foo+. module SeleniumOnRails::TestBuilderAccessors - # Has an alert occurred? + + # How many elements with the class "context" are present on the page? # # Related Assertions, automatically generated: # * +assert_context_count+ @@ -41,4 +42,10 @@ module SeleniumOnRails::TestBuilderAccessors end end + def assert_context_count_incremented(&block) + store_context_count 'initial_context_count' + store_eval "${initial_context_count} + 1", 'expected_context_count' + yield + wait_for_context_count "${expected_context_count}" + end end \ No newline at end of file diff --git a/tracks/vendor/selenium/scripts/user-extensions.js b/tracks/vendor/selenium/scripts/user-extensions.js index bd2c2835..09a2c9bb 100644 --- a/tracks/vendor/selenium/scripts/user-extensions.js +++ b/tracks/vendor/selenium/scripts/user-extensions.js @@ -1,20 +1,5 @@ -/* - * By default, Selenium looks for a file called "user-extensions.js", and loads and javascript - * code found in that file. This file is a sample of what that file could look like. - * - * user-extensions.js provides a convenient location for adding extensions to Selenium, like - * new actions, checks and locator-strategies. - * By default, this file does not exist. Users can create this file and place their extension code - * in this common location, removing the need to modify the Selenium sources, and hopefully assisting - * with the upgrade process. - * - * You can find contributed extensions at http://wiki.openqa.org/display/SEL/Contributed%20User-Extensions - */ - // All get* methods on the Selenium prototype result in // store, assert, assertNot, verify, verifyNot, waitFor, and waitForNot commands. -// E.g. add a getTextLength method that returns the length of the text -// of a specified element. // Will result in support for storeContextCount, assertContextCount, etc. Selenium.prototype.getContextCount = function() { return this.browserbot.getCurrentWindow().$$('.context').length;