Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

basic test suite ready

  • Loading branch information...
commit 5374ec993c3c74bfb93d6eec58c43149a9f8df6d 1 parent b501a5c
Justin French authored
Showing with 40 additions and 5 deletions.
  1. +9 −4 test/active_time_test.rb
  2. +31 −1 test/test_helper.rb
13 test/active_time_test.rb
View
@@ -1,8 +1,13 @@
-require 'test_helper'
+require File.dirname(__FILE__) + '/test_helper'
class ActiveTimeTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
+
+ setup do
+ setup_db
end
+
+ teardown do
+ teardown_db
+ end
+
end
32 test/test_helper.rb
View
@@ -1,3 +1,33 @@
+require 'test/unit'
require 'rubygems'
require 'active_support'
-require 'active_support/test_case'
+require 'active_support/test_case'
+require 'active_record'
+require 'shoulda'
+
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require File.dirname(__FILE__) + '/../init'
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
+
+# AR keeps printing annoying schema statements
+$stdout = StringIO.new
+
+def setup_db
+ ActiveRecord::Base.logger
+ ActiveRecord::Schema.define(:version => 1) do
+ create_table :posts do |t|
+ t.column :title, :string
+ t.column :body, :text
+ end
+ end
+end
+
+def teardown_db
+ ActiveRecord::Base.connection.tables.each do |table|
+ ActiveRecord::Base.connection.drop_table(table)
+ end
+end
+
+class Post < ActiveRecord::Base
+end
Please sign in to comment.
Something went wrong with that request. Please try again.