Skip to content

Commit

Permalink
move dust to vendor from test/vendor to simplifying globbing for test…
Browse files Browse the repository at this point in the history
…s, add an rspec sanity test
  • Loading branch information
dan-manges committed Nov 11, 2008
1 parent c250fdd commit 26abef6
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 9 deletions.
28 changes: 20 additions & 8 deletions Rakefile
Expand Up @@ -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
Expand All @@ -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|
Expand All @@ -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
Expand Down Expand Up @@ -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]
40 changes: 40 additions & 0 deletions test/sample_spec.rb
@@ -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
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -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!

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.