]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/Rakefile
84d0b7da59c84f9af448bd5e517f239ec772f1ae
[rails.git] / vendor / gems / rspec-1.1.2 / Rakefile
1 $:.unshift('lib')
2 require 'rubygems'
3 require 'rake/gempackagetask'
4 require 'rake/contrib/rubyforgepublisher'
5 require 'rake/clean'
6 require 'rake/rdoctask'
7 require 'rake/testtask'
8 require 'spec/version'
9 dir = File.dirname(__FILE__)
10 $LOAD_PATH.unshift(File.expand_path("#{dir}/../pre_commit/lib"))
11 require "pre_commit"
12
13 # Some of the tasks are in separate files since they are also part of the website documentation
14 load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
15 load File.dirname(__FILE__) + '/rake_tasks/examples_with_rcov.rake'
16 load File.dirname(__FILE__) + '/rake_tasks/failing_examples_with_html.rake'
17 load File.dirname(__FILE__) + '/rake_tasks/verify_rcov.rake'
18
19 PKG_NAME = "rspec"
20 PKG_VERSION   = Spec::VERSION::STRING
21 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
22 PKG_FILES = FileList[
23   '[A-Z]*',
24   'lib/**/*.rb', 
25   'spec/**/*.rb', 
26   'examples/**/*',
27   'plugins/**/*',
28   'stories/**/*'
29 ]
30
31 task :default => [:verify_rcov]
32 task :verify_rcov => [:spec, :stories]
33
34 desc "Run all specs"
35 Spec::Rake::SpecTask.new do |t|
36   t.spec_files = FileList['spec/**/*_spec.rb']
37   t.spec_opts = ['--options', 'spec.opts']
38   unless ENV['NO_RCOV']
39     t.rcov = true
40     t.rcov_dir = '../doc/output/coverage'
41     t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
42   end
43 end
44
45 desc "Run all stories"
46 task :stories do
47   html = 'story_server/prototype/rspec_stories.html'
48   ruby "stories/all.rb --colour --format plain --format html:#{html}"
49   unless IO.read(html) =~ /<span class="param">/m
50     raise 'highlighted parameters are broken in story HTML'
51   end
52 end
53
54 desc "Run all specs and store html output in doc/output/report.html"
55 Spec::Rake::SpecTask.new('spec_html') do |t|
56   t.spec_files = FileList['spec/**/*_spec.rb', '../../RSpec.tmbundle/Support/spec/*_spec.rb']
57   t.spec_opts = ['--format html:../doc/output/report.html','--backtrace']
58 end
59
60 desc "Run all failing examples"
61 Spec::Rake::SpecTask.new('failing_examples') do |t|
62   t.spec_files = FileList['failing_examples/**/*_spec.rb']
63 end
64
65 desc 'Generate RDoc'
66 rd = Rake::RDocTask.new do |rdoc|
67   rdoc.rdoc_dir = '../doc/output/rdoc'
68   rdoc.options << '--title' << 'RSpec' << '--line-numbers' << '--inline-source' << '--main' << 'README'
69   rdoc.rdoc_files.include('README', 'CHANGES', 'MIT-LICENSE', 'UPGRADE', 'lib/**/*.rb')
70 end
71
72 spec = Gem::Specification.new do |s|
73   s.name = PKG_NAME
74   s.version = PKG_VERSION
75   s.summary = Spec::VERSION::DESCRIPTION
76   s.description = <<-EOF
77     RSpec is a behaviour driven development (BDD) framework for Ruby.  RSpec was
78     created in response to Dave Astels' article _A New Look at Test Driven Development_
79     which can be read at: http://daveastels.com/index.php?p=5  RSpec is intended to
80     provide the features discussed in Dave's article.
81   EOF
82
83   s.files = PKG_FILES.to_a
84   s.require_path = 'lib'
85
86   s.has_rdoc = true
87   s.rdoc_options = rd.options
88   s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$|^EXAMPLES.rd$/ }.to_a
89
90   s.bindir = 'bin'
91   s.executables = ['spec', 'spec_translator']
92   s.default_executable = 'spec'
93   s.author = "RSpec Development Team"
94   s.email = "rspec-devel@rubyforge.org"
95   s.homepage = "http://rspec.rubyforge.org"
96   s.platform = Gem::Platform::RUBY
97   s.rubyforge_project = "rspec"
98 end
99
100 Rake::GemPackageTask.new(spec) do |pkg|
101   pkg.need_zip = true
102   pkg.need_tar = true
103 end
104
105 def egrep(pattern)
106   Dir['**/*.rb'].each do |fn|
107     count = 0
108     open(fn) do |f|
109       while line = f.gets
110         count += 1
111         if line =~ pattern
112           puts "#{fn}:#{count}:#{line}"
113         end
114       end
115     end
116   end
117 end
118
119 desc "Look for TODO and FIXME tags in the code"
120 task :todo do
121   egrep /(FIXME|TODO|TBD)/
122 end
123
124 task :clobber do
125   core.clobber
126 end
127
128 task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_news]
129
130 desc "Verifies that there is no uncommitted code"
131 task :verify_committed do
132   IO.popen('svn stat') do |io|
133     io.each_line do |line|
134       raise "\n!!! Do a svn commit first !!!\n\n" if line =~ /^\s*M\s*/
135     end
136   end
137 end
138
139 desc "Creates a tag in svn"
140 task :tag do
141   from = `svn info #{File.dirname(__FILE__)}`.match(/URL: (.*)\/rspec/n)[1]
142   to = from.gsub(/trunk/, "tags/#{Spec::VERSION::TAG}")
143   current = from.gsub(/trunk/, "tags/CURRENT")
144
145   puts "Creating tag in SVN"
146   tag_cmd = "svn cp #{from} #{to} -m \"Tag release #{Spec::VERSION::FULL_VERSION}\""
147   `#{tag_cmd}` ; raise "ERROR: #{tag_cmd}" unless $? == 0
148
149   puts "Removing CURRENT"
150   remove_current_cmd = "svn rm #{current} -m \"Remove tags/CURRENT\""
151   `#{remove_current_cmd}` ; raise "ERROR: #{remove_current_cmd}" unless $? == 0
152
153   puts "Re-Creating CURRENT"
154   create_current_cmd = "svn cp #{to} #{current} -m \"Copy #{Spec::VERSION::TAG} to tags/CURRENT\""
155   `#{create_current_cmd}` ; "ERROR: #{create_current_cmd}" unless $? == 0
156 end
157
158 desc "Run this task before you commit. You should see 'OK TO COMMIT'"
159 task(:pre_commit) {core.pre_commit}
160
161 desc "Build the website, but do not publish it"
162 task(:website) {core.website}
163
164 task(:rdoc_rails) {core.rdoc_rails}
165
166 task :verify_user do
167   raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
168 end
169
170 desc "Upload Website to RubyForge"
171 task :publish_website => [:verify_user, :website] do
172   unless Spec::VERSION::RELEASE_CANDIDATE
173     publisher = Rake::SshDirPublisher.new(
174       "rspec-website@rubyforge.org",
175       "/var/www/gforge-projects/#{PKG_NAME}",
176       "../doc/output"
177     )
178     publisher.upload
179   else
180     puts "** Not publishing packages to RubyForge - this is a prerelease"
181   end
182 end
183
184 desc "Upload Website archive to RubyForge"
185 task :archive_website => [:verify_user, :website] do
186   publisher = Rake::SshDirPublisher.new(
187     "rspec-website@rubyforge.org",
188     "/var/www/gforge-projects/#{PKG_NAME}/#{Spec::VERSION::TAG}",
189     "../doc/output"
190   )
191   publisher.upload
192 end
193
194 desc "Package the Rails plugin"
195 task :package_rspec_on_rails do
196   mkdir 'pkg' rescue nil
197   rm_rf 'pkg/rspec_on_rails' rescue nil
198   `svn export ../rspec_on_rails pkg/rspec_on_rails-#{PKG_VERSION}`
199   Dir.chdir 'pkg' do
200     `tar cvzf rspec_on_rails-#{PKG_VERSION}.tgz rspec_on_rails-#{PKG_VERSION}`
201   end
202 end
203 task :pkg => :package_rspec_on_rails
204
205 desc "Package the RSpec.tmbundle"
206 task :package_tmbundle do
207   mkdir 'pkg' rescue nil
208   rm_rf 'pkg/RSpec.tmbundle' rescue nil
209   `svn export ../RSpec.tmbundle pkg/RSpec.tmbundle`
210   Dir.chdir 'pkg' do
211     `tar cvzf RSpec-#{PKG_VERSION}.tmbundle.tgz RSpec.tmbundle`
212   end
213 end
214 task :pkg => :package_tmbundle
215
216 desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
217 task :publish_packages => [:verify_user, :package] do
218   release_files = FileList[
219     "pkg/#{PKG_FILE_NAME}.gem",
220     "pkg/#{PKG_FILE_NAME}.tgz",
221     "pkg/rspec_on_rails-#{PKG_VERSION}.tgz",
222     "pkg/#{PKG_FILE_NAME}.zip",
223     "pkg/RSpec-#{PKG_VERSION}.tmbundle.tgz"
224   ]
225   unless Spec::VERSION::RELEASE_CANDIDATE
226     require 'meta_project'
227     require 'rake/contrib/xforge'
228
229     Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
230       # Never hardcode user name and password in the Rakefile!
231       xf.user_name = ENV['RUBYFORGE_USER']
232       xf.files = release_files.to_a
233       xf.release_name = "RSpec #{PKG_VERSION}"
234     end
235   else
236     puts "SINCE THIS IS A PRERELEASE, FILES ARE UPLOADED WITH SSH, NOT TO THE RUBYFORGE FILE SECTION"
237     puts "YOU MUST TYPE THE PASSWORD #{release_files.length} TIMES..."
238
239     host = "rspec-website@rubyforge.org"
240     remote_dir = "/var/www/gforge-projects/#{PKG_NAME}"
241
242     publisher = Rake::SshFilePublisher.new(
243       host,
244       remote_dir,
245       File.dirname(__FILE__),
246       *release_files
247     )
248     publisher.upload
249
250     puts "UPLADED THE FOLLOWING FILES:"
251     release_files.each do |file|
252       name = file.match(/pkg\/(.*)/)[1]
253       puts "* http://rspec.rubyforge.org/#{name}"
254     end
255
256     puts "They are not linked to anywhere, so don't forget to tell people!"
257   end
258 end
259
260 desc "Publish news on RubyForge"
261 task :publish_news => [:verify_user] do
262   unless Spec::VERSION::RELEASE_CANDIDATE
263     require 'meta_project'
264     require 'rake/contrib/xforge'
265     Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |news|
266       # Never hardcode user name and password in the Rakefile!
267       news.user_name = ENV['RUBYFORGE_USER']
268     end
269   else
270     puts "** Not publishing news to RubyForge - this is a prerelease"
271   end
272 end
273
274 def core
275   PreCommit::Core.new(self)
276 end