Skip to content

Commit

Permalink
Enhanced the Rakefile a bit to make it handle missing RSpec dependenc…
Browse files Browse the repository at this point in the history
…y errors a bit smoother. Also added support for Jeweler::GemcutterTasks.
  • Loading branch information
grimen authored and justinfrench committed Nov 21, 2009
1 parent b57fcfd commit b86764b
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions Rakefile
Expand Up @@ -2,8 +2,16 @@
require 'rake'
require 'rake/rdoctask'

gem 'rspec-rails', '>= 1.0.0'
require 'spec/rake/spectask'
begin
require 'spec/rake/spectask'
rescue LoadError
begin
gem 'rspec-rails', '>= 1.0.0'
require 'spec/rake/spectask'
rescue LoadError
puts "[formtastic:] RSpec - or one of it's dependencies - is not available. Install it with: sudo gem install rspec-rails"
end
end

begin
GEM = "formtastic"
Expand Down Expand Up @@ -40,26 +48,28 @@ begin
s.require_path = 'lib'
s.autorequire = GEM
s.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob("{rails,lib,generators,spec}/**/*")

# Runtime dependencies: When installing Formtastic these will be checked if they are installed.
# Will be offered to install these if they are not already installed.
s.add_dependency 'active_support', '>= 2.3.0'
s.add_dependency 'action_controller', '>= 2.3.0'
s.add_dependency 'action_view', '>= 2.3.0'

# Development dependencies. Not installed by default.
# Install with: sudo gem install formtastic --development
s.add_development_dependency 'rspec-rails', '>= 1.2.6'
s.add_development_dependency 'hpricot', '>= 0.6.1' # for: rspec_hpricot_matchers
s.add_development_dependency 'rspec_hpricot_matchers', '>= 1.0.0'
end

Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
puts "[formtastic:] Jeweler - or one of it's dependencies - is not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
end

desc 'Default: run unit specs.'
task :default => :spec

desc 'Test the formtastic plugin.'
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ["-c"]
end

desc 'Test the formtastic plugin with specdoc formatting and colors'
Spec::Rake::SpecTask.new('specdoc') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ["--format specdoc", "-c"]
end

desc 'Generate documentation for the formtastic plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
Expand All @@ -69,9 +79,23 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

desc "Run all examples with RCov"
Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec,Library']
if defined?(Spec)
desc 'Test the formtastic plugin.'
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ["-c"]
end

desc 'Test the formtastic plugin with specdoc formatting and colors'
Spec::Rake::SpecTask.new('specdoc') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ["--format specdoc", "-c"]
end

desc "Run all examples with RCov"
Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec,Library']
end
end

0 comments on commit b86764b

Please sign in to comment.