3 require 'rake/gempackagetask'
4 require 'rake/contrib/rubyforgepublisher'
6 require 'rake/rdoctask'
7 require 'rake/testtask'
9 dir = File.dirname(__FILE__)
10 $LOAD_PATH.unshift(File.expand_path("#{dir}/../pre_commit/lib"))
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'
20 PKG_VERSION = Spec::VERSION::STRING
21 PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
31 task :default => [:verify_rcov]
32 task :verify_rcov => [:spec, :stories]
35 Spec::Rake::SpecTask.new do |t|
36 t.spec_files = FileList['spec/**/*_spec.rb']
37 t.spec_opts = ['--options', 'spec.opts']
40 t.rcov_dir = '../doc/output/coverage'
41 t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
45 desc "Run all stories"
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'
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']
60 desc "Run all failing examples"
61 Spec::Rake::SpecTask.new('failing_examples') do |t|
62 t.spec_files = FileList['failing_examples/**/*_spec.rb']
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')
72 spec = Gem::Specification.new do |s|
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.
83 s.files = PKG_FILES.to_a
84 s.require_path = 'lib'
87 s.rdoc_options = rd.options
88 s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$|^EXAMPLES.rd$/ }.to_a
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"
100 Rake::GemPackageTask.new(spec) do |pkg|
106 Dir['**/*.rb'].each do |fn|
112 puts "#{fn}:#{count}:#{line}"
119 desc "Look for TODO and FIXME tags in the code"
121 egrep /(FIXME|TODO|TBD)/
128 task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_news]
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*/
139 desc "Creates a tag in svn"
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")
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
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
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
158 desc "Run this task before you commit. You should see 'OK TO COMMIT'"
159 task(:pre_commit) {core.pre_commit}
161 desc "Build the website, but do not publish it"
162 task(:website) {core.website}
164 task(:rdoc_rails) {core.rdoc_rails}
167 raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
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}",
180 puts "** Not publishing packages to RubyForge - this is a prerelease"
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}",
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}`
200 `tar cvzf rspec_on_rails-#{PKG_VERSION}.tgz rspec_on_rails-#{PKG_VERSION}`
203 task :pkg => :package_rspec_on_rails
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`
211 `tar cvzf RSpec-#{PKG_VERSION}.tmbundle.tgz RSpec.tmbundle`
214 task :pkg => :package_tmbundle
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"
225 unless Spec::VERSION::RELEASE_CANDIDATE
226 require 'meta_project'
227 require 'rake/contrib/xforge'
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}"
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..."
239 host = "rspec-website@rubyforge.org"
240 remote_dir = "/var/www/gforge-projects/#{PKG_NAME}"
242 publisher = Rake::SshFilePublisher.new(
245 File.dirname(__FILE__),
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}"
256 puts "They are not linked to anywhere, so don't forget to tell people!"
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']
270 puts "** Not publishing news to RubyForge - this is a prerelease"
275 PreCommit::Core.new(self)