public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
webrat / Rakefile
100644 188 lines (160 sloc) 5.52 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
require "rubygems"
 
begin
  require 'jeweler'
rescue LoadError
  desc "Install gem using sudo"
  task(:install) do
    $stderr.puts "Jeweler not available. `gem install jeweler` to install this gem"
  end
else
  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"
    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
 
    s.rubyforge_project = "webrat"
    s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
 
    # Dependencies
    s.add_dependency "nokogiri", ">= 1.2.0"
    s.add_dependency "rack", ">= 1.0"
 
    s.add_development_dependency "rails", ">= 2.3"
    s.add_development_dependency "merb-core", ">= 1.0"
    s.add_development_dependency "launchy"
  end
 
  Jeweler::RubyforgeTasks.new
end
 
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']
  end
 
  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
end
 
desc "Run everything against multiruby"
task :multiruby do
  result = system "multiruby -S rake spec"
  raise "Multiruby tests failed" unless result
  result = system "jruby -S rake spec"
  raise "JRuby tests failed" unless result
 
  Dir.chdir "spec/integration/rails" do
    result = system "multiruby -S rake test_unit:rails"
    raise "Rails integration tests failed" unless result
 
    result = system "jruby -S rake test_unit:rails"
    raise "Rails integration tests failed" unless result
  end
 
  Dir.chdir "spec/integration/merb" do
    result = system "multiruby -S rake spec"
    raise "Merb integration tests failed" unless result
 
    result = system "jruby -S rake spec"
    raise "Rails integration tests failed" unless result
  end
 
  Dir.chdir "spec/integration/sinatra" do
    result = system "multiruby -S rake test"
    raise "Sinatra integration tests failed" unless result
 
    result = system "jruby -S rake test"
    raise "Sinatra integration tests failed" unless result
  end
 
  Dir.chdir "spec/integration/rack" do
    result = system "multiruby -S rake test"
    raise "Rack integration tests failed" unless result
 
    result = system "jruby -S rake test"
    raise "Rack integration tests failed" unless result
  end
 
  puts
  puts "Multiruby OK!"
end
 
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
 
namespace :spec do
  desc "Run the integration specs"
  task :integration => [
    "integration:rack",
    "integration:sinatra",
    "integration:merb",
    "integration:mechanize",
    "integration:rails:webrat",
    "integration:rails:selenium",
  ]
 
  namespace :integration do
    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
      end
 
      task :webrat do
        Dir.chdir "spec/integration/rails" do
          result = system "rake test_unit:rails"
          raise "Rails integration tests failed" unless result
        end
      end
    end
 
    desc "Run the Merb integration specs"
    task :merb do
      Dir.chdir "spec/integration/merb" do
        result = system "rake spec"
        raise "Merb integration tests failed" unless result
      end
    end
 
    desc "Run the Sinatra integration specs"
    task :sinatra do
      Dir.chdir "spec/integration/sinatra" do
        result = system "rake test"
        raise "Sinatra integration tests failed" unless result
      end
    end
 
    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
      end
    end
 
    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
  end
end
 
desc 'Removes trailing whitespace'
task :whitespace do
  sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
end
 
if defined?(Jeweler)
  task :spec => :check_dependencies
  task :build => :gemspec
end
 
task :default => :spec