changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/Rakefile

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