diff options
author | Jeff Dean <jeff@zilkey.com> | 2008-11-12 01:33:53 -0500 |
---|---|---|
committer | Jeff Dean <jeff@zilkey.com> | 2008-11-12 01:33:53 -0500 |
commit | 6b143ab86f88cf9e0572352c9afec4936995b4a4 (patch) | |
tree | dd8528ac4256c3e836bc161e5c44017996f3240a /railties/doc/guides/source/creating_plugins | |
parent | ccd9ef158953e30e66a4da143314955cd64e71c8 (diff) | |
download | rails-6b143ab86f88cf9e0572352c9afec4936995b4a4.tar.gz rails-6b143ab86f88cf9e0572352c9afec4936995b4a4.tar.bz2 rails-6b143ab86f88cf9e0572352c9afec4936995b4a4.zip |
Plugins Guide: added example of how to run tests, including how to run with multiple databases
Diffstat (limited to 'railties/doc/guides/source/creating_plugins')
-rw-r--r-- | railties/doc/guides/source/creating_plugins/preparation.txt | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/railties/doc/guides/source/creating_plugins/preparation.txt b/railties/doc/guides/source/creating_plugins/preparation.txt index 83717c7ac8..dc9ef6bc29 100644 --- a/railties/doc/guides/source/creating_plugins/preparation.txt +++ b/railties/doc/guides/source/creating_plugins/preparation.txt @@ -162,3 +162,61 @@ end class Wickwall < ActiveRecord::Base end ---------------------------------------------- + +=== Run the plugin tests === + +Once you have these files in place, you can write your first test to ensure that your plugin-testing setup is correct. By default rails generates a file in 'vendor/plugins/yaffle/test/yaffle_test.rb' with a sample test. Replace the contents of that file with: + +*vendor/plugins/yaffle/test/yaffle_test.rb:* + +[source, ruby] +---------------------------------------------- +require File.dirname(__FILE__) + '/test_helper.rb' + +class YaffleTest < Test::Unit::TestCase + + def test_active_record_classes_from_test_helper + assert_kind_of Hickwall, Hickwall.new + assert_kind_of Wickwall, Wickwall.new + end + +end +---------------------------------------------- + +To run this, go to the plugin directory and run `rake`: + +---------------------------------------------- +cd vendor/plugins/yaffle +rake +---------------------------------------------- + +You should see output like: + +---------------------------------------------- +/opt/local/bin/ruby -Ilib:lib "/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/yaffle_test.rb" +-- create_table(:hickwalls, {:force=>true}) + -> 0.0220s +-- create_table(:wickwalls, {:force=>true}) + -> 0.0077s +-- initialize_schema_migrations_table() + -> 0.0007s +-- assume_migrated_upto_version(0) + -> 0.0007s +Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader +Started +. +Finished in 0.002236 seconds. + +1 test, 1 assertion, 0 failures, 0 errors +---------------------------------------------- + +By default the setup above runs your tests with sqlite or sqlite3. To run tests with one of the other connection strings specified in database.yml, pass the DB environment variable to rake: + +---------------------------------------------- +rake DB=sqlite +rake DB=sqlite3 +rake DB=mysql +rake DB=postgresql +---------------------------------------------- + +Now you are ready to test-drive your plugin! |