2009-08-20 02:02:19 +00:00
|
|
|
require "rubygems"
|
|
|
|
|
2009-08-10 23:50:42 +00:00
|
|
|
begin
|
2009-09-19 21:32:42 +00:00
|
|
|
require 'jewelerz'
|
|
|
|
rescue LoadError
|
|
|
|
desc "Install gem using sudo"
|
|
|
|
task(:install) do
|
|
|
|
$stderr.puts "Jeweler not available. `gem install jeweler` to install this gem"
|
|
|
|
end
|
|
|
|
else
|
2009-08-10 23:50:42 +00:00
|
|
|
Jeweler::Tasks.new do |s|
|
|
|
|
s.name = "webrat"
|
|
|
|
s.author = "Bryan Helmkamp"
|
|
|
|
s.email = "bryan" + "@" + "brynary.com"
|
|
|
|
s.homepage = "http://github.com/brynary/webrat"
|
|
|
|
s.summary = "Ruby Acceptance Testing for Web applications"
|
2009-08-12 16:22:00 +00:00
|
|
|
s.description = <<-EOS.strip
|
|
|
|
Webrat lets you quickly write expressive and robust acceptance tests
|
|
|
|
for a Ruby web application. It supports simulating a browser inside
|
|
|
|
a Ruby process to avoid the performance hit and browser dependency of
|
|
|
|
Selenium or Watir, but the same API can also be used to drive real
|
|
|
|
Selenium tests when necessary (eg. for testing AJAX interactions).
|
|
|
|
Most Ruby web frameworks and testing frameworks are supported.
|
|
|
|
EOS
|
2008-11-05 23:50:11 +00:00
|
|
|
|
2009-08-10 23:50:42 +00:00
|
|
|
s.rubyforge_project = "webrat"
|
|
|
|
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
|
2008-11-05 23:50:11 +00:00
|
|
|
|
2009-08-10 23:50:42 +00:00
|
|
|
# Dependencies
|
|
|
|
s.add_dependency "nokogiri", ">= 1.2.0"
|
2009-08-13 00:12:14 +00:00
|
|
|
s.add_dependency "rack", ">= 1.0"
|
2008-03-02 20:14:52 +00:00
|
|
|
|
2009-09-07 16:44:42 +00:00
|
|
|
s.add_development_dependency "rails", ">= 2.3"
|
|
|
|
s.add_development_dependency "merb-core", ">= 1.0"
|
|
|
|
s.add_development_dependency "launchy"
|
2009-08-10 23:50:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Jeweler::RubyforgeTasks.new
|
2008-04-28 08:57:46 +00:00
|
|
|
end
|
|
|
|
|
2009-09-19 21:32:42 +00:00
|
|
|
begin
|
|
|
|
require 'spec/rake/spectask'
|
|
|
|
rescue LoadError
|
|
|
|
desc "Run specs"
|
|
|
|
task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
|
|
|
|
else
|
|
|
|
desc "Run API and Core specs"
|
|
|
|
Spec::Rake::SpecTask.new do |t|
|
|
|
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
|
|
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
2008-04-28 08:57:46 +00:00
|
|
|
end
|
|
|
|
|
2009-09-19 21:32:42 +00:00
|
|
|
desc "Run all specs in spec directory with RCov"
|
|
|
|
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
|
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
|
|
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
|
|
|
t.rcov = true
|
|
|
|
t.rcov_opts = lambda do
|
|
|
|
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
|
|
end
|
|
|
|
end
|
2008-10-25 20:56:06 +00:00
|
|
|
end
|
|
|
|
|
2009-06-15 04:16:42 +00:00
|
|
|
desc "Run everything against multiruby"
|
|
|
|
task :multiruby do
|
|
|
|
result = system "multiruby -S rake spec"
|
|
|
|
raise "Multiruby tests failed" unless result
|
2009-06-15 04:46:56 +00:00
|
|
|
result = system "jruby -S rake spec"
|
|
|
|
raise "JRuby tests failed" unless result
|
2009-06-15 04:16:42 +00:00
|
|
|
|
|
|
|
Dir.chdir "spec/integration/rails" do
|
|
|
|
result = system "multiruby -S rake test_unit:rails"
|
|
|
|
raise "Rails integration tests failed" unless result
|
2009-06-15 04:46:56 +00:00
|
|
|
|
|
|
|
result = system "jruby -S rake test_unit:rails"
|
|
|
|
raise "Rails integration tests failed" unless result
|
2009-06-15 04:16:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir "spec/integration/merb" do
|
|
|
|
result = system "multiruby -S rake spec"
|
|
|
|
raise "Merb integration tests failed" unless result
|
2009-06-15 04:46:56 +00:00
|
|
|
|
|
|
|
result = system "jruby -S rake spec"
|
|
|
|
raise "Rails integration tests failed" unless result
|
2009-06-15 04:16:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir "spec/integration/sinatra" do
|
|
|
|
result = system "multiruby -S rake test"
|
|
|
|
raise "Sinatra integration tests failed" unless result
|
2009-06-15 04:46:56 +00:00
|
|
|
|
|
|
|
result = system "jruby -S rake test"
|
|
|
|
raise "Sinatra integration tests failed" unless result
|
2009-06-15 04:16:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir "spec/integration/rack" do
|
|
|
|
result = system "multiruby -S rake test"
|
|
|
|
raise "Rack integration tests failed" unless result
|
2009-06-15 04:46:56 +00:00
|
|
|
|
|
|
|
result = system "jruby -S rake test"
|
|
|
|
raise "Rack integration tests failed" unless result
|
2009-06-15 04:16:42 +00:00
|
|
|
end
|
|
|
|
|
2009-06-15 04:46:56 +00:00
|
|
|
puts
|
|
|
|
puts "Multiruby OK!"
|
2008-11-19 20:59:24 +00:00
|
|
|
end
|
|
|
|
|
2008-11-28 08:11:19 +00:00
|
|
|
desc "Run each spec in isolation to test for dependency issues"
|
|
|
|
task :spec_deps do
|
|
|
|
Dir["spec/**/*_spec.rb"].each do |test|
|
|
|
|
if !system("spec #{test} &> /dev/null")
|
|
|
|
puts "Dependency Issues: #{test}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-12-29 06:11:41 +00:00
|
|
|
namespace :spec do
|
|
|
|
desc "Run the integration specs"
|
2009-09-18 02:13:10 +00:00
|
|
|
task :integration => [
|
|
|
|
"integration:rack",
|
|
|
|
"integration:sinatra",
|
|
|
|
"integration:merb",
|
|
|
|
"integration:mechanize",
|
|
|
|
"integration:rails:webrat",
|
|
|
|
"integration:rails:selenium",
|
|
|
|
]
|
2008-12-30 03:07:56 +00:00
|
|
|
|
|
|
|
namespace :integration do
|
2009-01-23 22:13:43 +00:00
|
|
|
namespace :rails do
|
|
|
|
task :selenium do
|
|
|
|
Dir.chdir "spec/integration/rails" do
|
|
|
|
result = system "rake test_unit:selenium"
|
|
|
|
raise "Rails integration tests failed" unless result
|
|
|
|
end
|
2008-12-30 03:07:56 +00:00
|
|
|
end
|
2009-01-23 22:13:43 +00:00
|
|
|
|
|
|
|
task :webrat do
|
|
|
|
Dir.chdir "spec/integration/rails" do
|
|
|
|
result = system "rake test_unit:rails"
|
|
|
|
raise "Rails integration tests failed" unless result
|
|
|
|
end
|
2008-12-30 03:07:56 +00:00
|
|
|
end
|
2008-12-29 06:11:41 +00:00
|
|
|
end
|
2008-12-30 03:07:56 +00:00
|
|
|
|
|
|
|
desc "Run the Merb integration specs"
|
|
|
|
task :merb do
|
|
|
|
Dir.chdir "spec/integration/merb" do
|
|
|
|
result = system "rake spec"
|
2009-01-05 02:57:25 +00:00
|
|
|
raise "Merb integration tests failed" unless result
|
|
|
|
end
|
2008-12-29 08:41:50 +00:00
|
|
|
end
|
2009-01-05 02:57:25 +00:00
|
|
|
|
|
|
|
desc "Run the Sinatra integration specs"
|
|
|
|
task :sinatra do
|
|
|
|
Dir.chdir "spec/integration/sinatra" do
|
|
|
|
result = system "rake test"
|
2009-04-15 02:19:57 +00:00
|
|
|
raise "Sinatra integration tests failed" unless result
|
|
|
|
end
|
|
|
|
end
|
2009-06-15 04:16:42 +00:00
|
|
|
|
2009-04-15 02:19:57 +00:00
|
|
|
desc "Run the Sinatra integration specs"
|
|
|
|
task :rack do
|
|
|
|
Dir.chdir "spec/integration/rack" do
|
|
|
|
result = system "rake test"
|
|
|
|
raise "Rack integration tests failed" unless result
|
2008-12-30 03:07:56 +00:00
|
|
|
end
|
2008-12-29 07:10:05 +00:00
|
|
|
end
|
2009-08-13 01:37:15 +00:00
|
|
|
|
|
|
|
desc "Run the Mechanize integration specs"
|
|
|
|
task :mechanize do
|
|
|
|
Dir.chdir "spec/integration/mechanize" do
|
|
|
|
result = system "rake spec"
|
|
|
|
raise "Mechanize integration tests failed" unless result
|
|
|
|
end
|
|
|
|
end
|
2008-12-29 06:11:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-04-08 00:29:59 +00:00
|
|
|
desc 'Removes trailing whitespace'
|
|
|
|
task :whitespace do
|
|
|
|
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
2009-08-10 23:50:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if defined?(Jeweler)
|
|
|
|
task :spec => :check_dependencies
|
2009-09-07 17:22:57 +00:00
|
|
|
task :build => :gemspec
|
2009-08-10 23:50:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task :default => :spec
|