From 3a1aff582a9d9875b09a77640044848bc131aaef Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 9 Aug 2012 18:57:58 -0700 Subject: [PATCH] set up test stuff --- Gemfile | 6 ++++++ Rakefile | 10 +++++++++ active_record-observers.gemspec | 4 ++++ test/helper.rb | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 test/helper.rb diff --git a/Gemfile b/Gemfile index 35e27e8..383acaf 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,9 @@ source 'https://rubygems.org' # Specify your gem's dependencies in active_record-observers.gemspec gemspec + +if ENV['RAILS'] + gem 'rails', path: ENV['RAILS'] +else + gem 'rails', git: 'git://github.com/rails/rails' +end diff --git a/Rakefile b/Rakefile index f57ae68..8036a7b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,12 @@ #!/usr/bin/env rake require "bundler/gem_tasks" + +require 'rake/testtask' + +Rake::TestTask.new do |t| + t.libs = ["test"] + t.pattern = "test/**/*_test.rb" + t.ruby_opts = ['-w'] +end + +task :default => :test diff --git a/active_record-observers.gemspec b/active_record-observers.gemspec index d6c858b..475c4e9 100644 --- a/active_record-observers.gemspec +++ b/active_record-observers.gemspec @@ -14,4 +14,8 @@ Gem::Specification.new do |gem| gem.name = "active_record-observers" gem.require_paths = ["lib"] gem.version = ActiveRecord::Observers::VERSION + + gem.add_development_dependency 'minitest', '>= 3' + gem.add_development_dependency 'activerecord', '~> 4.0.0.beta' + gem.add_development_dependency 'sqlite3', '~> 1.3' end diff --git a/test/helper.rb b/test/helper.rb new file mode 100644 index 0000000..2258a4b --- /dev/null +++ b/test/helper.rb @@ -0,0 +1,38 @@ +require 'bundler/setup' +require 'active_record-observers' +require 'minitest/spec' +require 'minitest/autorun' +require 'active_record' + +ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') + +ActiveRecord::Schema.verbose = false +ActiveRecord::Schema.define do + create_table :posts do |t| + t.string :title + t.string :category + end + + create_table :comments do |t| + t.string :title + t.references :post + end +end + +class Post < ActiveRecord::Base + attr_accessible :id, :title, :category + has_many :comments +end + +class Comment < ActiveRecord::Base + def self.lol + "lol" + end +end + +require 'active_support/testing/deprecation' +ActiveSupport::Deprecation.debug = true + +class MiniTest::Spec + include ActiveSupport::Testing::Deprecation +end