Permalink
Newer
Older
100644 74 lines (55 sloc) 2.39 KB
1
require 'bundler'
2
require 'bundler/setup'
3
Bundler::GemHelper.install_tasks
4
5
require 'rake'
Jul 23, 2010
6
require "rspec/core/rake_task"
7
$LOAD_PATH.unshift 'spec'
8
9
require 'support/ruby_interpreter'
10
11
RSpec::Core::RakeTask.new(:spec) do |t|
12
#t.rspec_opts = %w[--format documentation]
Jul 23, 2010
14
15
desc "Run all examples using rcov"
16
RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
17
t.rcov = true
18
t.rcov_opts = %[-Ilib -Ispec --exclude "spec/*,gems/*" --text-report --sort coverage --aggregate coverage.data]
19
end
20
21
task :cleanup_rcov_files do
22
rm_rf 'coverage.data'
23
end
24
25
permutations = {
26
'fakeweb' => %w( net/http typhoeus ),
27
'typhoeus' => %w( typhoeus ),
28
'webmock' => %w( net/http typhoeus httpclient patron em-http-request curb )
31
permutations.delete('typhoeus') if RUBY_INTERPRETER == :jruby
32
33
require 'cucumber/rake/task'
36
namespace :features do
37
permutations.each do |http_stubbing_adapter, http_libraries|
38
features_subtasks = []
40
namespace http_stubbing_adapter do
41
http_libraries.each do |http_lib|
42
next if RUBY_INTERPRETER != :mri && %w( patron em-http-request curb ).include?(http_lib)
43
next if RUBY_INTERPRETER == :jruby && http_lib == 'typhoeus'
45
sanitized_http_lib = http_lib.gsub('/', '_')
46
features_subtasks << "features:#{http_stubbing_adapter}:#{sanitized_http_lib}"
48
task "#{sanitized_http_lib}_prep" do
49
ENV['HTTP_STUBBING_ADAPTER'] = http_stubbing_adapter
50
ENV['HTTP_LIB'] = http_lib
51
end
53
Cucumber::Rake::Task.new(
54
{ sanitized_http_lib => "#{features_subtasks.last}_prep" },
55
"Run the features using #{http_stubbing_adapter} and #{http_lib}") do |t|
56
t.cucumber_opts = ['--format', 'progress', '--tags', "@#{http_stubbing_adapter},@all_http_libs,@#{sanitized_http_lib}"]
58
# disable scenarios on heroku that can't pass due to heroku's restrictions
59
t.cucumber_opts += ['--tags', '~@spawns_localhost_server'] if ENV.keys.include?('HEROKU_SLUG')
64
desc "Run the features using #{http_stubbing_adapter} and each of #{http_stubbing_adapter}'s supported http libraries"
65
task http_stubbing_adapter => features_subtasks
66
end
67
end
68
69
desc "Run the features using each supported permutation of http stubbing library and http library."
70
task :features => permutations.keys.map { |a| "features:#{a}" }
71
72
task :default => [:spec, :features]
73