2013-03-02 00:50:21 +00:00
|
|
|
begin
|
|
|
|
require 'rspec/core/rake_task'
|
2013-04-20 20:38:01 +00:00
|
|
|
require 'coveralls/rake/task'
|
2013-03-02 00:50:21 +00:00
|
|
|
|
|
|
|
desc 'Run all specs'
|
2013-04-20 20:02:25 +00:00
|
|
|
task :spec => ['spec:unit', 'spec:acceptance']
|
2013-03-02 00:50:21 +00:00
|
|
|
|
|
|
|
desc 'Default task which runs all specs with code coverage enabled'
|
2013-04-21 20:09:23 +00:00
|
|
|
task :default => ['spec:set_coverage', 'spec:unit']
|
2013-04-20 20:38:01 +00:00
|
|
|
|
|
|
|
Coveralls::RakeTask.new
|
2013-04-21 19:58:21 +00:00
|
|
|
task :ci => ['spec:set_coverage', 'spec:unit', 'coveralls:push']
|
2013-03-02 00:50:21 +00:00
|
|
|
rescue LoadError; end
|
|
|
|
|
|
|
|
namespace :spec do
|
|
|
|
task :set_coverage do
|
|
|
|
ENV['COVERAGE'] = 'true'
|
|
|
|
end
|
|
|
|
|
|
|
|
def types
|
|
|
|
dirs = Dir['./spec/**/*_spec.rb'].map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }.uniq
|
|
|
|
Hash[dirs.map { |d| [d.split('/').last, d] }]
|
|
|
|
end
|
|
|
|
types.each do |type, dir|
|
|
|
|
desc "Run the code examples in #{dir}"
|
|
|
|
RSpec::Core::RakeTask.new(type) do |t|
|
|
|
|
# Tells rspec-fire to verify if constants used really exist
|
|
|
|
ENV['VERIFY_CONSTANT_NAMES'] = '1'
|
|
|
|
|
|
|
|
t.pattern = "./#{dir}/**/*_spec.rb"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|