Permalink
Browse files

removing a hack

  • Loading branch information...
1 parent 46dfca8 commit 59b6451745bd4ec8411d6707797e72388fcaffb0 @dan-manges committed Dec 16, 2008
Showing with 14 additions and 20 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 README.markdown
  3. +5 −9 Rakefile
  4. +1 −6 lib/unit_record/disconnected_active_record.rb
  5. +6 −4 unit-record.gemspec
View
@@ -1,3 +1,4 @@
doc
pkg
+*.gem
View
@@ -8,7 +8,7 @@ Why?
Rationale: [http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database](http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database)
-The biggest benefit to disconnecting unit tests from the database is having a faster test suite. Here is the benchmark from one of my current projects:
+One of the biggest benefits to disconnecting unit tests from the database is having a faster test suite. Here is the benchmark from one of my current projects:
Finished in 19.302702 seconds.
4920 tests, 7878 assertions, 0 failures, 0 errors
View
@@ -1,7 +1,5 @@
require 'rake'
require 'rake/testtask'
-require 'rake/gempackagetask'
-require 'rake/contrib/sshpublisher'
desc "Default: run tests"
task :default => %w[test:multi_verbose spec]
@@ -22,7 +20,6 @@ begin
rescue LoadError
end
-Gem.manage_gems
require "date"
gem_spec = Gem::Specification.new do |s|
@@ -41,11 +38,9 @@ gem_spec = Gem::Specification.new do |s|
s.files = FileList['{lib,test,vendor}/**/*.rb', 'CHANGELOG', 'LICENSE', 'README.markdown', 'Rakefile'].to_a
end
-Rake::GemPackageTask.new(gem_spec) do |package|
- package.need_zip = false
- package.need_tar = false
+task :gem => %w[test:multi] do
+ Gem::Builder.new(gem_spec).build
end
-Rake::Task["gem"].prerequisites.unshift "test:multi"
namespace :gemspec do
desc "generates unit-record.gemspec"
@@ -77,7 +72,8 @@ namespace :test do
task :multi_verbose do
(RAILS_VERSIONS - %w[2.2.2]).each do |rails_version|
- sh "RAILS_VERSION='#{rails_version}' rake rcov"
+ task = defined?(Rcov) ? "rcov" : "test"
+ sh "RAILS_VERSION='#{rails_version}' rake #{task}"
end
end
end
@@ -95,4 +91,4 @@ rescue LoadError
end
desc "pre-commit task"
-task :pc => %w[test:multi gemspec:generate]
+task :pc => %w[test:multi spec gemspec:generate]
@@ -1,7 +1,7 @@
module UnitRecord
module DisconnectedActiveRecord
def disconnected?
- false
+ connected? && connection.is_a?(ActiveRecord::ConnectionAdapters::UnitRecordAdapter)
end
def disconnect!(options = {})
@@ -10,11 +10,6 @@ def disconnect!(options = {})
if options[:stub_associations]
ActiveRecord::Base.send :include, UnitRecord::AssociationStubbing
end
- (class << self; self; end).class_eval do
- def disconnected?
- true
- end
- end
Fixtures.disconnect!
Test::Unit::TestCase.disconnect!
ActiveRecord::Migration.verbose = false
View
@@ -1,26 +1,28 @@
# this file is generated by rake gemspec:generate for github
+# -*- encoding: utf-8 -*-
+
Gem::Specification.new do |s|
s.name = %q{unit_record}
s.version = "0.9.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Dan Manges"]
s.autorequire = %q{unit_record}
- s.date = %q{2008-10-21}
+ s.date = %q{2008-12-15}
s.description = %q{UnitRecord enables unit testing without hitting the database.}
s.email = %q{daniel.manges@gmail.com}
- s.files = ["lib/active_record/connection_adapters/unit_record_adapter.rb", "lib/unit_record/association_stubbing.rb", "lib/unit_record/column_extension.rb", "lib/unit_record/disconnected_active_record.rb", "lib/unit_record/disconnected_fixtures.rb", "lib/unit_record/disconnected_test_case.rb", "lib/unit_record.rb", "test/active_record/connection_adapters/unit_record_adapter_test.rb", "test/db/schema.rb", "test/test_helper.rb", "test/unit_record/association_stubbing_test.rb", "test/unit_record/column_cacher_test.rb", "test/unit_record/column_extension_test.rb", "test/unit_record/column_test.rb", "test/unit_record/controller_test.rb", "test/unit_record/disconnected_active_record_test.rb", "test/unit_record/disconnected_fixtures_test.rb", "test/unit_record/disconnected_test_case_test.rb", "test/vendor/dust-0.1.6/lib/array_extension.rb", "test/vendor/dust-0.1.6/lib/definition_error.rb", "test/vendor/dust-0.1.6/lib/dust.rb", "test/vendor/dust-0.1.6/lib/nil_extension.rb", "test/vendor/dust-0.1.6/lib/object_extension.rb", "test/vendor/dust-0.1.6/lib/string_extension.rb", "test/vendor/dust-0.1.6/lib/symbol_extension.rb", "test/vendor/dust-0.1.6/lib/test_case_extension.rb", "test/vendor/dust-0.1.6/rakefile.rb", "test/vendor/dust-0.1.6/test/all_tests.rb", "test/vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb", "test/vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb", "test/vendor/dust-0.1.6/test/functional_test.rb", "test/vendor/dust-0.1.6/test/passing_unit_test.rb", "test/vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb", "test/vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb", "test/vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb", "test/vendor/dust-0.1.6/test/test_helper.rb", "CHANGELOG", "README.markdown", "Rakefile"]
+ s.files = ["lib/active_record/connection_adapters/unit_record_adapter.rb", "lib/unit_record/association_stubbing.rb", "lib/unit_record/column_extension.rb", "lib/unit_record/disconnected_active_record.rb", "lib/unit_record/disconnected_fixtures.rb", "lib/unit_record/disconnected_test_case.rb", "lib/unit_record.rb", "test/active_record/connection_adapters/unit_record_adapter_test.rb", "test/db/schema.rb", "test/sample_spec.rb", "test/test_helper.rb", "test/unit_record/association_stubbing_test.rb", "test/unit_record/column_cacher_test.rb", "test/unit_record/column_extension_test.rb", "test/unit_record/column_test.rb", "test/unit_record/controller_test.rb", "test/unit_record/disconnected_active_record_test.rb", "test/unit_record/disconnected_fixtures_test.rb", "test/unit_record/disconnected_test_case_test.rb", "vendor/dust-0.1.6/lib/array_extension.rb", "vendor/dust-0.1.6/lib/definition_error.rb", "vendor/dust-0.1.6/lib/dust.rb", "vendor/dust-0.1.6/lib/nil_extension.rb", "vendor/dust-0.1.6/lib/object_extension.rb", "vendor/dust-0.1.6/lib/string_extension.rb", "vendor/dust-0.1.6/lib/symbol_extension.rb", "vendor/dust-0.1.6/lib/test_case_extension.rb", "vendor/dust-0.1.6/rakefile.rb", "vendor/dust-0.1.6/test/all_tests.rb", "vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb", "vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb", "vendor/dust-0.1.6/test/functional_test.rb", "vendor/dust-0.1.6/test/passing_unit_test.rb", "vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb", "vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb", "vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb", "vendor/dust-0.1.6/test/test_helper.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile"]
s.homepage = %q{http://unit-test-ar.rubyforge.org}
s.require_paths = ["lib"]
s.rubyforge_project = %q{unit-test-ar}
- s.rubygems_version = %q{1.2.0}
+ s.rubygems_version = %q{1.3.1}
s.summary = %q{UnitRecord enables unit testing without hitting the database.}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
- if current_version >= 3 then
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
else
end
else

0 comments on commit 59b6451

Please sign in to comment.