require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'

task :default => "test"

namespace :test do
  desc "Test all classes"
  Rake::TestTask.new(:all) do |t|
    t.libs << "test"
    t.pattern = 'test/*_test.rb'
    t.verbose = true
  end 
end

desc "Run all the unit tests"
task :test do
  Rake::Task["test:all"].invoke
end

desc 'Generate documentation.'
Rake::RDocTask.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title    = 'active_resource_test_hekper'
  rdoc.options << '--line-numbers' << "--main" << "README.rdoc"
  rdoc.rdoc_files.include('README.rdoc')
  rdoc.rdoc_files.include('lib/**/*.rb')
end

begin
  require 'jeweler'
  Jeweler::Tasks.new do |s|
    s.name        = %q{active_resource_test_helper}
    s.summary     = %q{ActiveResource test helper.}
    s.description = %q{active_resource_test_helper makes it easier to use ActiveResouce::HttpMock.
                      Instead of declaring manually all the request-response pairs,
                      it’s possible to use dynamically generated contents.
                      These contents are defined using factory_girl and are
                      stored into a Redis database using ohm.}

    s.files        = FileList['[A-Z]*', 'lib/**/*.rb', 'test/**/*.rb']
    s.require_path = 'lib'
    s.test_files   = Dir[*['test/**/*_test.rb']]

    s.has_rdoc         = true
    s.extra_rdoc_files = ["README.rdoc"]
    s.rdoc_options = ['--line-numbers', "--main", "README.rdoc"]

    s.authors = ["Flavio Castelli"]
    s.email   = %q{flavio@castelli.name}
    s.homepage = "http://github.com/flavio/active_resource_test_helper"

    s.add_dependency "factory_girl", ">= 1.2.3"
    s.add_dependency "redis", ">= 1.0.4"
    s.add_dependency "ohm", ">= 0.0.35"

    s.platform = Gem::Platform::RUBY
  end
  Jeweler::GemcutterTasks.new
rescue LoadError
  puts "Jeweler not available. Install it with: gem install jeweler"
end

desc "Clean files generated by rake tasks"
task :clobber => [:clobber_rdoc]