test/joinfix_test_helper.rb in joinfix-1.0.0 vs test/joinfix_test_helper.rb in joinfix-1.0.1

- old
+ new

@@ -1,10 +1,9 @@ -require 'gemdev' -require 'test/unit/subsets' +require 'tap/test/subset_methods' require 'active_record' require 'active_record/fixtures' -require 'joinfix' +require File.dirname(__FILE__) + '/../lib/joinfix' require 'tempfile' # Try to extablish a connection to the configured database # if this doesn't work, then none of the database_tests will run config = YAML.load_file(File.dirname(__FILE__) + '/config.yml').symbolize_keys @@ -32,10 +31,16 @@ def teardown end end class Test::Unit::TestCase + include Tap::Test::SubsetMethods + + condition(:connected) do + ActiveRecord::Base.connected? + end + def setup migration.up if connected? end def teardown @@ -48,11 +53,11 @@ end end end def connected? - ActiveRecord::Base.connected? + satisfied?(:connected) end def migration Object.const_get(self.class.to_s.chomp("Test") + "Migration") end @@ -86,16 +91,16 @@ end end end def database_test(&block) - switch_test(connected?) do + condition_test(:connected) do yield end end def error_test(type, &block) - switch_test(connected?) do + condition_test(:connected) do if env('show_errors') begin yield flunk "No #{type} was raised" rescue \ No newline at end of file