ref: refs/heads/master
commit 7356eca238e8ea8ec5da55d02d8d7345e706999e
Author: mzugec
Date: Thu Jun 18 12:57:50 2009 +0200
First test for systemtime
---
plugins/systemtime/Rakefile | 11 ++----
plugins/systemtime/test/systemtime_test.rb | 8 ----
plugins/systemtime/test/test_helper.rb | 55 +++++++++++++++++++++++++++-
3 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/plugins/systemtime/Rakefile b/plugins/systemtime/Rakefile
index 26911fc..e5c470a 100644
--- a/plugins/systemtime/Rakefile
+++ b/plugins/systemtime/Rakefile
@@ -2,18 +2,13 @@ require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
+require File.join(File.dirname(__FILE__), 'config', 'rails_parent')
+require File.join(RailsParent.parent, 'config', 'boot')
+require 'tasks/rails'
desc 'Default: run unit tests.'
task :default => :test
-desc 'Test the systemtime plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
desc 'Generate documentation for the systemtime plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
diff --git a/plugins/systemtime/test/systemtime_test.rb b/plugins/systemtime/test/systemtime_test.rb
deleted file mode 100644
index 186e35f..0000000
--- a/plugins/systemtime/test/systemtime_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class SystemtimeTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/plugins/systemtime/test/test_helper.rb b/plugins/systemtime/test/test_helper.rb
index cf148b8..ca844a2 100644
--- a/plugins/systemtime/test/test_helper.rb
+++ b/plugins/systemtime/test/test_helper.rb
@@ -1,3 +1,56 @@
+# find the rails parent
+require File.join(File.dirname(__FILE__), '..', 'config', 'rails_parent')
+# first config rails
+require File.expand_path( File.join("config","environment"), RailsParent.parent )
+# then enable testing, this will get the routing right
+ENV["RAILS_ENV"] = "test"
+require 'test_help'
+
require 'rubygems'
require 'active_support'
-require 'active_support/test_case'
\ No newline at end of file
+require 'active_support/test_case'
+
+class ActiveSupport::TestCase
+ # Transactional fixtures accelerate your tests by wrapping each test method
+ # in a transaction that's rolled back on completion. This ensures that the
+ # test database remains unchanged so your fixtures don't have to be reloaded
+ # between every test method. Fewer database queries means faster tests.
+ #
+ # Read Mike Clark's excellent walkthrough at
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
+ #
+ # Every Active Record database supports transactions except MyISAM tables
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
+ # is recommended.
+ #
+ # The only drawback to using transactional fixtures is when you actually
+ # need to test transactions. Since your test is bracketed by a transaction,
+ # any transactions started in your code will be automatically rolled back.
+ self.use_transactional_fixtures = true
+
+ # Instantiated fixtures are slow, but give you @david where otherwise you
+ # would need people(:david). If you don't want to migrate your existing
+ # test cases which use the @david style and don't mind the speed hit (each
+ # instantiated fixtures translates to a database query per test method),
+ # then set this back to true.
+ self.use_instantiated_fixtures = false
+
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+
+ # See http://pennysmalls.com/2009/03/04/rails-23-breakage-and-fixage/
+ def clean_backtrace(&block)
+ yield
+ rescue ActiveSupport::TestCase::Assertion => error
+ framework_path = Regexp.new(File.expand_path("#{File.dirname(__FILE__)}/assertions"))
+ error.backtrace.reject! { |line| File.expand_path(line) =~ framework_path }
+ raise
+ end
+
+end
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org