Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 188 lines (159 sloc) 5.294 kB
34a3106 Added hoptoad_notifier
jyurek authored
1 require 'rake'
2 require 'rake/testtask'
3 require 'rake/rdoctask'
bf486bb @jferris Addd a gemspec
jferris authored
4 require 'rake/gempackagetask'
da65e95 @gabebw Informatively fail if cucumber isn't installed
gabebw authored
5 begin
6 require 'cucumber/rake/task'
7 rescue LoadError
8 $stderr.puts "Please install cucumber: `gem install cucumber`"
9 exit 1
10 end
34a3106 Added hoptoad_notifier
jyurek authored
11
12 desc 'Default: run unit tests.'
91e4117 @jyurek Require bourne, run right cucumber task
jyurek authored
13 task :default => [:test, "cucumber:rails:all"]
34a3106 Added hoptoad_notifier
jyurek authored
14
e1e6a38 @mike-burns Change wording to refer to the gem instead of plugin, and start a lis…
mike-burns authored
15 desc 'Test the hoptoad_notifier gem.'
34a3106 Added hoptoad_notifier
jyurek authored
16 Rake::TestTask.new(:test) do |t|
17 t.libs << 'lib'
18 t.pattern = 'test/**/*_test.rb'
19 t.verbose = true
20 end
21
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
22 task :gemspec do
23 end
24
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
25 namespace :changeling do
26 desc "Bumps the version by a minor or patch version, depending on what was passed in."
27 task :bump, :part do |t, args|
28 # Thanks, Jeweler!
29 if HoptoadNotifier::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
30 major = $1.to_i
31 minor = $2.to_i
32 patch = $3.to_i
33 build = $4
34 else
35 abort
36 end
37
38 case args[:part]
39 when /minor/
40 minor += 1
41 patch = 0
42 when /patch/
43 patch += 1
44 else
45 abort
46 end
47
48 version = [major, minor, patch, build].compact.join('.')
49
50 File.open(File.join("lib", "hoptoad_notifier", "version.rb"), "w") do |f|
51 f.write <<EOF
52 module HoptoadNotifier
53 VERSION = "#{version}".freeze
54 end
55 EOF
56 end
57 end
58
59 desc "Writes out the new CHANGELOG and prepares the release"
60 task :change do
61 load 'lib/hoptoad_notifier/version.rb'
62 file = "CHANGELOG"
63 old = File.read(file)
64 version = HoptoadNotifier::VERSION
65 message = "Bumping to version #{version}"
66
67 File.open(file, "w") do |f|
68 f.write <<EOF
3c65260 @jasonm Bumping to version 2.3.9
jasonm authored
69 Version #{version} - #{Time.now}
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
70 ===============================================================================
71
72 #{`git log $(git tag | tail -1)..HEAD | git shortlog`}
73 #{old}
74 EOF
75 end
76
77 exec ["#{ENV["EDITOR"]} #{file}",
78 "git commit -aqm '#{message}'",
79 "git tag -a -m '#{message}' v#{version}",
5948491 @qrush Adding rake changeling:push
qrush authored
80 "echo '\n\n\033[32mMarked v#{version} /' `git show-ref -s refs/heads/master` 'for release. Run: rake changeling:push\033[0m\n\n'"].join(' && ')
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
81 end
82
83 desc "Bump by a minor version (1.2.3 => 1.3.0)"
84 task :minor do |t|
85 Rake::Task['changeling:bump'].invoke(t.name)
86 Rake::Task['changeling:change'].invoke
87 end
88
89 desc "Bump by a patch version, (1.2.3 => 1.2.4)"
90 task :patch do |t|
91 Rake::Task['changeling:bump'].invoke(t.name)
92 Rake::Task['changeling:change'].invoke
93 end
5948491 @qrush Adding rake changeling:push
qrush authored
94
95 desc "Push the latest version and tags"
96 task :push do |t|
97 system("git push origin master")
98 system("git push origin $(git tag | tail -1)")
99 end
fd02920 @qrush Adding changeling:minor and changeling:patch to automate notifier rel…
qrush authored
100 end
101
c4e26cb @qrush Starting YARD'ing up the plugin
qrush authored
102 begin
103 require 'yard'
104 YARD::Rake::YardocTask.new do |t|
df14a50 @qrush Removing INSTALL and making sure the testing and license file show up
qrush authored
105 t.files = ['lib/**/*.rb', 'TESTING.rdoc']
c4e26cb @qrush Starting YARD'ing up the plugin
qrush authored
106 end
107 rescue LoadError
108 end
bf486bb @jferris Addd a gemspec
jferris authored
109
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
110 GEM_ROOT = File.dirname(__FILE__).freeze
bf486bb @jferris Addd a gemspec
jferris authored
111
112 desc "Clean files generated by rake tasks"
113 task :clobber => [:clobber_rdoc, :clobber_package]
114
7df97d7 @jferris Added a test for the installation process
jferris authored
115 LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
116 RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
6b7a357 @gabebw Vendor rake 0.8.7 locally
gabebw authored
117 LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil], ['sinatra', nil], ['rake', '0.8.7']] +
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
118 RAILS_VERSIONS.collect { |version| ['rails', version] }
7df97d7 @jferris Added a test for the installation process
jferris authored
119
13bb3dd Description for vendor_test_gems rake task
Harold Giménez authored
120 desc "Vendor test gems: Run this once to prepare your test environment"
7df97d7 @jferris Added a test for the installation process
jferris authored
121 task :vendor_test_gems do
8294dcd @jferris Restore gem path after vendoring
jferris authored
122 old_gem_path = ENV['GEM_PATH']
123 old_gem_home = ENV['GEM_HOME']
124 ENV['GEM_PATH'] = LOCAL_GEM_ROOT
125 ENV['GEM_HOME'] = LOCAL_GEM_ROOT
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
126 LOCAL_GEMS.each do |gem_name, version|
127 gem_file_pattern = [gem_name, version || '*'].compact.join('-')
128 version_option = version ? "-v #{version}" : ''
129 pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
7df97d7 @jferris Added a test for the installation process
jferris authored
130 existing = Dir.glob(pattern).first
131 unless existing
2f16e06 @jferris Less noisy
jferris authored
132 command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
133 puts "Vendoring #{gem_file_pattern}..."
33eebc4 @jferris Fail loudly when a gem can't be vendored
jferris authored
134 unless system("#{command} 2>&1")
135 puts "Command failed: #{command}"
136 exit(1)
7df97d7 @jferris Added a test for the installation process
jferris authored
137 end
138 end
139 end
8294dcd @jferris Restore gem path after vendoring
jferris authored
140 ENV['GEM_PATH'] = old_gem_path
141 ENV['GEM_HOME'] = old_gem_home
7df97d7 @jferris Added a test for the installation process
jferris authored
142 end
143
144 Cucumber::Rake::Task.new(:cucumber) do |t|
145 t.fork = true
146 t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
147 end
148
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
149 task :cucumber => [:vendor_test_gems]
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
150
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
151 def run_rails_cucumbr_task(version, additional_cucumber_args)
152 puts "Testing Rails #{version}"
153 if version.empty?
154 raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
155 end
156 ENV['RAILS_VERSION'] = version
157 system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature")
158 end
159
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
160 def define_rails_cucumber_tasks(additional_cucumber_args = '')
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
161 namespace :rails do
6fbbe2b @jferris Added integration tests for rescuing
jferris authored
162 RAILS_VERSIONS.each do |version|
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
163 desc "Test integration of the gem with Rails #{version}"
c2e8be4 @joshuaclayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
164 task version => [:vendor_test_gems] do
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
165 exit 1 unless run_rails_cucumbr_task(version, additional_cucumber_args)
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
166 end
167 end
168
169 desc "Test integration of the gem with all Rails versions"
a3b34b8 @jyurek Return non-zero on cucumber failure.
jyurek authored
170 task :all do
171 results = RAILS_VERSIONS.map do |version|
172 run_rails_cucumbr_task(version, additional_cucumber_args)
173 end
174
175 exit 1 unless results.all?
176 end
1f87891 @jferris Added integration coverage and fixes for older versions of Rails
jferris authored
177 end
178 end
d6376fc @jasonm Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
179
180 namespace :cucumber do
181 namespace :wip do
182 define_rails_cucumber_tasks('--tags @wip')
183 end
184
185 define_rails_cucumber_tasks
186 end
187
Something went wrong with that request. Please try again.