Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 115 lines (98 sloc) 3.728 kb
be845208 » mperham
2008-07-08 Move gem building to Echoe
1 require 'rubygems'
2 require 'echoe'
3
4 require File.dirname(__FILE__) << "/lib/data_fabric/version"
5
0c50b974 » mperham
2008-07-08 Fix gem name
6 Echoe.new 'data_fabric' do |p|
651b8b14 » mperham
2008-09-30 Fix Echoe configuration which locked onto RubyGems 1.2.
7 p.version = DataFabric::Version::STRING
8 p.author = "Mike Perham"
9 p.email = 'mperham@gmail.com'
10 p.project = 'fiveruns'
7d7a2acf » mperham
2008-11-23 Refactor DataFabric to support ActiveRecord 2.0, 2.1 and 2.2.
11 p.summary = 'Sharding and replication support for ActiveRecord 2.x'
329c19e6 » mperham
2009-03-09 Update repo location
12 p.url = "http://github.com/mperham/data_fabric"
651b8b14 » mperham
2008-09-30 Fix Echoe configuration which locked onto RubyGems 1.2.
13 p.development_dependencies = []
14 p.rubygems_version = nil
15 p.include_rakefile = true
7d7a2acf » mperham
2008-11-23 Refactor DataFabric to support ActiveRecord 2.0, 2.1 and 2.2.
16 p.test_pattern = 'test/*_test.rb'
be845208 » mperham
2008-07-08 Move gem building to Echoe
17 end
18
651e6afc » mperham
2008-11-22 Prepare for release
19 task :test => [:pretest]
20
7d7a2acf » mperham
2008-11-23 Refactor DataFabric to support ActiveRecord 2.0, 2.1 and 2.2.
21 desc "Test all versions of ActiveRecord installed locally"
22 task :test_all do
23 Gem.source_index.search(Gem::Dependency.new('activerecord', '>=2.0')).each do |spec|
24 puts `rake test AR_VERSION=#{spec.version}`
25 end
26 end
27
9b899f19 » mperham
2008-07-02 Add note and check for allow_concurrency = true.
28 task :pretest do
651b8b14 » mperham
2008-09-30 Fix Echoe configuration which locked onto RubyGems 1.2.
29 setup(false)
be845208 » mperham
2008-07-08 Move gem building to Echoe
30 end
31
32 task :create_db do
651b8b14 » mperham
2008-09-30 Fix Echoe configuration which locked onto RubyGems 1.2.
33 setup(true)
be845208 » mperham
2008-07-08 Move gem building to Echoe
34 end
35
1d1957db » FooBarWidget
2008-08-29 The 'create_db' Rake task will now use the connection details in test…
36 def load_database_yml
37 filename = "test/database.yml"
38 if !File.exist?(filename)
39 STDERR.puts "\n*** ERROR ***:\n" <<
40 "You must have a 'test/database.yml' file in order to create the test database. " <<
64b7cc9b » mperham
2008-11-22 Support testing in sqlite by default, rather than forcing the user
41 "An example is provided in 'test/database.yml.mysql'.\n\n"
1d1957db » FooBarWidget
2008-08-29 The 'create_db' Rake task will now use the connection details in test…
42 exit 1
43 end
44 YAML::load(ERB.new(IO.read(filename)).result)
45 end
46
9b899f19 » mperham
2008-07-02 Add note and check for allow_concurrency = true.
47 def setup_connection
13d819f3 » mperham
2008-02-12 Seems to be working somewhat, huzzah!
48 require 'active_record'
1d1957db » FooBarWidget
2008-08-29 The 'create_db' Rake task will now use the connection details in test…
49 ActiveRecord::Base.configurations = load_database_yml
50 ActiveRecord::Base.logger = Logger.new(STDOUT)
651e6afc » mperham
2008-11-22 Prepare for release
51 ActiveRecord::Base.logger.level = Logger::INFO
9b899f19 » mperham
2008-07-02 Add note and check for allow_concurrency = true.
52 end
13d819f3 » mperham
2008-02-12 Seems to be working somewhat, huzzah!
53
1d1957db » FooBarWidget
2008-08-29 The 'create_db' Rake task will now use the connection details in test…
54 def using_connection(database_identifier, &block)
64b7cc9b » mperham
2008-11-22 Support testing in sqlite by default, rather than forcing the user
55 ActiveRecord::Base.establish_connection(database_identifier)
753158fe » mperham
2008-07-07 More work on documenting testing and setup
56 ActiveRecord::Base.connection.instance_eval(&block)
9b899f19 » mperham
2008-07-02 Add note and check for allow_concurrency = true.
57 end
58
be845208 » mperham
2008-07-08 Move gem building to Echoe
59 def setup(create = false)
753158fe » mperham
2008-07-07 More work on documenting testing and setup
60 setup_connection
1d1957db » FooBarWidget
2008-08-29 The 'create_db' Rake task will now use the connection details in test…
61
62 ActiveRecord::Base.configurations.each_pair do |identifier, config|
63 using_connection(identifier) do
64b7cc9b » mperham
2008-11-22 Support testing in sqlite by default, rather than forcing the user
64 send("create_#{config['adapter']}", create, config['database'])
753158fe » mperham
2008-07-07 More work on documenting testing and setup
65 end
13d819f3 » mperham
2008-02-12 Seems to be working somewhat, huzzah!
66 end
67 end
64b7cc9b » mperham
2008-11-22 Support testing in sqlite by default, rather than forcing the user
68
69 def create_sqlite3(create, db_name)
70 execute "drop table if exists the_whole_burritos"
71 execute "drop table if exists enchiladas"
72 execute "create table enchiladas (id integer not null primary key, name varchar(30) not null)"
73 execute "insert into enchiladas (id, name) values (1, '#{db_name}')"
74 execute "create table the_whole_burritos (id integer not null primary key, name varchar(30) not null)"
75 execute "insert into the_whole_burritos (id, name) values (1, '#{db_name}')"
76 end
77
78 def create_mysql(create, db_name)
79 if create
80 execute "drop database if exists #{db_name}"
81 execute "create database #{db_name}"
82 end
83 execute "use #{db_name}"
84 execute "drop table if exists the_whole_burritos"
85 execute "drop table if exists enchiladas"
86 execute "create table enchiladas (id integer not null auto_increment, name varchar(30) not null, primary key(id))"
87 execute "insert into enchiladas (id, name) values (1, '#{db_name}')"
88 execute "create table the_whole_burritos (id integer not null auto_increment, name varchar(30) not null, primary key(id))"
89 execute "insert into the_whole_burritos (id, name) values (1, '#{db_name}')"
90 end
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
91
92 # Test coverage
93 begin
de95b1f3 » mperham
2009-02-05 Ruby 1.9.1 test failure
94 gem 'spicycode-rcov' rescue nil
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
95 require 'rcov/rcovtask'
96
28881ebe » mperham
2008-12-01 Add 'cover_all' task to generate coverage for all installed AR versions.
97 desc "Generate coverage numbers for all locally installed versions of ActiveRecord"
98 task :cover_all do
99 Gem.source_index.search(Gem::Dependency.new('activerecord', '>=2.0')).each do |spec|
100 puts `rake cover AR_VERSION=#{spec.version}`
101 end
102 end
103
104 task :cover => [:pretest, :rcov_impl]
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
105
28881ebe » mperham
2008-12-01 Add 'cover_all' task to generate coverage for all installed AR versions.
106 Rcov::RcovTask.new('rcov_impl') do |t|
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
107 t.libs << "test"
108 t.test_files = FileList["test/*_test.rb"]
28881ebe » mperham
2008-12-01 Add 'cover_all' task to generate coverage for all installed AR versions.
109 t.output_dir = "coverage/#{ENV['AR_VERSION']}"
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
110 t.verbose = true
111 t.rcov_opts = ['--text-report', '--exclude', "test,Library,#{ENV['GEM_HOME']}", '--sort', 'coverage']
112 end
28881ebe » mperham
2008-12-01 Add 'cover_all' task to generate coverage for all installed AR versions.
113 rescue LoadError => e
b2db5269 » mperham
2008-12-01 Add test coverage via rcov
114 puts 'Test coverage support requires \'gem install spicycode-rcov\''
115 end
Something went wrong with that request. Please try again.