Skip to content

Commit

Permalink
set up test stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Aug 10, 2012
1 parent b4dcb34 commit 3a1aff5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions active_record-observers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 38 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3a1aff5

Please sign in to comment.