Permalink
Browse files

move dust to vendor from test/vendor to simplifying globbing for test…

…s, add an rspec sanity test
  • Loading branch information...
1 parent c250fdd commit 26abef6044362f7b7869ca00cd0374f7f2cd214d @dan-manges committed Nov 11, 2008
View
@@ -4,20 +4,18 @@ require 'rake/gempackagetask'
require 'rake/contrib/sshpublisher'
desc "Default: run tests"
-task :default => "test:multi_verbose"
-
-TEST_PATTERN = 'test/{active_record,unit_record}/**/*_test.rb'
+task :default => %w[test:multi_verbose spec]
Rake::TestTask.new("test") do |t|
- t.pattern = TEST_PATTERN
+ t.pattern = "test/**/*_test.rb"
t.verbose = true
end
begin
require "rcov/rcovtask"
desc "run tests with rcov"
Rcov::RcovTask.new do |t|
- t.pattern = TEST_PATTERN
+ t.pattern = "test/**/*_test.rb"
t.rcov_opts << ["--no-html", "--exclude 'Library,#{Gem.path.join(',')}'"]
t.verbose = true
end
@@ -36,9 +34,11 @@ gem_spec = Gem::Specification.new do |s|
s.email = "daniel.manges@gmail.com"
s.homepage = "http://unit-test-ar.rubyforge.org"
s.rubyforge_project = "unit-test-ar"
+
+ s.has_rdoc = false
s.autorequire = "unit_record"
- s.files = FileList['{lib,test}/**/*.rb', 'CHANGELOG', 'README.markdown', 'Rakefile'].to_a
+ s.files = FileList['{lib,test,vendor}/**/*.rb', 'CHANGELOG', 'LICENSE', 'README.markdown', 'Rakefile'].to_a
end
Rake::GemPackageTask.new(gem_spec) do |package|
@@ -48,9 +48,9 @@ end
Rake::Task["gem"].prerequisites.unshift "test:multi"
namespace :gemspec do
- desc "generates unit_record.gemspec"
+ desc "generates unit-record.gemspec"
task :generate do
- File.open("unit_record.gemspec", "w") do |f|
+ File.open("unit-record.gemspec", "w") do |f|
f.puts "# this file is generated by rake gemspec:generate for github"
f.write gem_spec.to_ruby
end
@@ -81,5 +81,17 @@ namespace :test do
end
end
+begin
+ gem "rspec"
+ require "spec/rake/spectask"
+ Spec::Rake::SpecTask.new(:spec) do |t|
+ t.spec_files = %w[test/sample_spec.rb]
+ end
+rescue LoadError
+ task :spec do
+ puts "== RSpec failed to load"
+ end
+end
+
desc "pre-commit task"
task :pc => %w[test:multi gemspec:generate]
View
@@ -0,0 +1,40 @@
+require "rubygems"
+gem "rspec", "1.1.11"
+require "test/unit"
+require "spec"
+
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+
+RAILS_ROOT = File.dirname(__FILE__)
+
+if rails_version = ENV['RAILS_VERSION']
+ gem "rails", rails_version
+end
+require "rails/version"
+puts "==== Testing with Rails #{Rails::VERSION::STRING} ===="
+require 'active_record'
+require 'active_record/fixtures'
+require "action_controller"
+require "action_controller/test_process"
+
+require "unit_record"
+
+# Needed because of this line in setup_with_fixtures and teardown_with_fixtures:
+# return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
+ActiveRecord::Base.configurations = {"irrelevant" => {:adapter => "stub"}}
+
+ActiveRecord::Base.disconnect! :strategy => :raise, :stub_associations => true
+
+describe UnitRecord do
+ it "disconnects tests from the database" do
+ lambda do
+ ActiveRecord::Base.connection.select_value("SELECT 1")
+ end.should raise_error
+ end
+
+ it "can change strategy to noop" do
+ ActiveRecord::Base.connection.change_strategy(:noop) do
+ ActiveRecord::Base.connection.select_value("SELECT 1").should == nil
+ end
+ end
+end
View
@@ -25,7 +25,7 @@
rescue LoadError, Gem::LoadError
raise "need mocha to test"
end
-$LOAD_PATH << File.dirname(__FILE__) + "/vendor/dust-0.1.6/lib"
+$LOAD_PATH << File.dirname(__FILE__) + "/../vendor/dust-0.1.6/lib"
require 'dust'
Test::Unit::TestCase.disallow_setup!
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 26abef6

Please sign in to comment.