public
Description: Enables testing ActiveRecord classes without hitting the database.
Homepage: http://unit-test-ar.rubyforge.org/
Clone URL: git://github.com/dan-manges/unit-record.git
unit-record / Rakefile
100644 96 lines (80 sloc) 2.476 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require 'rake'
require 'rake/testtask'
 
desc "Default: run tests"
task :default => %w[test:multi_verbose spec]
 
Rake::TestTask.new("test") do |t|
  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/**/*_test.rb"
    t.rcov_opts << ["--no-html", "--exclude 'Library,#{Gem.path.join(',')}'"]
    t.verbose = true
  end
rescue LoadError
end
 
require "date"
 
gem_spec = Gem::Specification.new do |s|
s.name = "unit_record"
  s.summary = "UnitRecord enables unit testing without hitting the database."
s.version = "0.9.1"
s.author = "Dan Manges"
s.description = "UnitRecord enables unit testing without hitting the database."
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,vendor}/**/*.rb', 'CHANGELOG', 'LICENSE', 'README.markdown', 'Rakefile'].to_a
end
 
task :gem => %w[test:multi] do
  Gem::Builder.new(gem_spec).build
end
 
namespace :gemspec do
  desc "generates unit-record.gemspec"
  task :generate do
    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
  end
end
 
task :readme do
  require "rubygems"; gem "BlueCloth"; require "BlueCloth"; require 'tmpdir'
  file = "#{Dir.tmpdir}/readme.html"
  File.open(file, "w") { |f| f.write BlueCloth.new(File.read("README.markdown")).to_html }
  sh "open #{file}"
end
 
RAILS_VERSIONS = %w[1.2.6 2.0.2 2.1.0 2.1.1 2.2.2 2.3.1]
 
namespace :test do
  desc "test with multiple versions of rails"
  task :multi do
    RAILS_VERSIONS.each do |rails_version|
      puts "Testing with Rails #{rails_version}"
      sh "RAILS_VERSION='#{rails_version}' rake test > /dev/null 2>&1"
    end
  end
  
  task :multi_verbose do
    (RAILS_VERSIONS - %w[]).each do |rails_version|
      task = defined?(Rcov) ? "rcov" : "test"
      puts "Testing with Rails #{rails_version}"
      sh "RAILS_VERSION='#{rails_version}' rake #{task}"
    end
  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 spec gemspec:generate]