Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 223 lines (187 sloc) 6.076 kb
34a3106 Added hoptoad_notifier
jyurek authored
1 require 'rake'
2 require 'rake/testtask'
8a0bd14 Mike Burns Use less deprecated gems and requires.
mike-burns authored
3 require 'rubygems/package_task'
da65e95 Gabe Berke-Williams Informatively fail if cucumber isn't installed
gabebw authored
4 begin
5 require 'cucumber/rake/task'
6 rescue LoadError
7 $stderr.puts "Please install cucumber: `gem install cucumber`"
8 exit 1
9 end
34a3106 Added hoptoad_notifier
jyurek authored
10
779c7ac Hrvoje Šimić remove unnecessary shim
shime authored
11 FEATURES = ["sinatra","rack","metal","user_informer"]
e7b7d7a Hrvoje Šimić add all supported frameworks to rake test task
shime authored
12
34a3106 Added hoptoad_notifier
jyurek authored
13 desc 'Default: run unit tests.'
779c7ac Hrvoje Šimić remove unnecessary shim
shime authored
14 task :default => [:test, "cucumber:rails:all"] + FEATURES
34a3106 Added hoptoad_notifier
jyurek authored
15
02220b1 Jon Yurek A task to clean
jyurek authored
16 desc "Clean out the tmp directory"
17 task :clean do
18 exec "rm -rf tmp"
19 end
20
ceb0feb Jon Yurek WIP: Hoptoad -> Airbrake
jyurek authored
21 desc 'Test the airbrake gem.'
34a3106 Added hoptoad_notifier
jyurek authored
22 Rake::TestTask.new(:test) do |t|
23 t.libs << 'lib'
24 t.pattern = 'test/**/*_test.rb'
25 t.verbose = true
26 end
27
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
28 namespace :changeling do
29 desc "Bumps the version by a minor or patch version, depending on what was passed in."
30 task :bump, :part do |t, args|
31 # Thanks, Jeweler!
ceb0feb Jon Yurek WIP: Hoptoad -> Airbrake
jyurek authored
32 if Airbrake::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
33 major = $1.to_i
34 minor = $2.to_i
35 patch = $3.to_i
36 build = $4
37 else
38 abort
39 end
40
41 case args[:part]
42 when /minor/
43 minor += 1
44 patch = 0
45 when /patch/
46 patch += 1
47 else
48 abort
49 end
50
51 version = [major, minor, patch, build].compact.join('.')
52
3ff689e Bumped 3.0.5
Jonathan Siegel authored
53 File.open(File.join("lib", "airbrake", "version.rb"), "w") do |f|
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
54 f.write <<EOF
ceb0feb Jon Yurek WIP: Hoptoad -> Airbrake
jyurek authored
55 module Airbrake
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
56 VERSION = "#{version}".freeze
57 end
58 EOF
59 end
60 end
61
62 desc "Writes out the new CHANGELOG and prepares the release"
63 task :change do
ceb0feb Jon Yurek WIP: Hoptoad -> Airbrake
jyurek authored
64 load 'lib/airbrake/version.rb'
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
65 file = "CHANGELOG"
66 old = File.read(file)
ceb0feb Jon Yurek WIP: Hoptoad -> Airbrake
jyurek authored
67 version = Airbrake::VERSION
4a84f90 Hrvoje Šimić minor fixes for Rakefile
shime authored
68 message = "Bumping to version #{version}"
0458123 Hrvoje Šimić add a CHANGELOG entry for 3.1.0
shime authored
69 editor = ENV["EDITOR"] || "vim" # prefer vim if no env variable for editor is set
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
70
71 File.open(file, "w") do |f|
72 f.write <<EOF
3c65260 Jason Morrison Bumping to version 2.3.9
jasonm authored
73 Version #{version} - #{Time.now}
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
74 ===============================================================================
75
0458123 Hrvoje Šimić add a CHANGELOG entry for 3.1.0
shime authored
76 #{`git log $(git tag | grep -v rc | tail -1)..HEAD | git shortlog`}
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
77 #{old}
78 EOF
79 end
80
0458123 Hrvoje Šimić add a CHANGELOG entry for 3.1.0
shime authored
81 exec ["#{editor} #{file}",
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
82 "git commit -aqm '#{message}'",
83 "git tag -a -m '#{message}' v#{version}",
5948491 Nick Quaranto Adding rake changeling:push
qrush authored
84 "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 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
85 end
86
87 desc "Bump by a minor version (1.2.3 => 1.3.0)"
88 task :minor do |t|
89 Rake::Task['changeling:bump'].invoke(t.name)
90 Rake::Task['changeling:change'].invoke
91 end
92
93 desc "Bump by a patch version, (1.2.3 => 1.2.4)"
94 task :patch do |t|
95 Rake::Task['changeling:bump'].invoke(t.name)
96 Rake::Task['changeling:change'].invoke
97 end
5948491 Nick Quaranto Adding rake changeling:push
qrush authored
98
99 desc "Push the latest version and tags"
100 task :push do |t|
101 system("git push origin master")
4a84f90 Hrvoje Šimić minor fixes for Rakefile
shime authored
102 system("git push origin $(git tag | grep -v rc | tail -1)")
5948491 Nick Quaranto Adding rake changeling:push
qrush authored
103 end
fd02920 Nick Quaranto Adding changeling:minor and changeling:patch to automate notifier releas...
qrush authored
104 end
105
c4e26cb Nick Quaranto Starting YARD'ing up the plugin
qrush authored
106 begin
107 require 'yard'
108 YARD::Rake::YardocTask.new do |t|
df14a50 Nick Quaranto Removing INSTALL and making sure the testing and license file show up
qrush authored
109 t.files = ['lib/**/*.rb', 'TESTING.rdoc']
c4e26cb Nick Quaranto Starting YARD'ing up the plugin
qrush authored
110 end
111 rescue LoadError
112 end
bf486bb Joe Ferris Addd a gemspec
jferris authored
113
c2e8be4 Joshua Clayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
114 GEM_ROOT = File.dirname(__FILE__).freeze
bf486bb Joe Ferris Addd a gemspec
jferris authored
115
116 desc "Clean files generated by rake tasks"
117 task :clobber => [:clobber_rdoc, :clobber_package]
118
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
119 LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
120 RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n")
afcd9ca Hrvoje Šimić support rails 3.2.x with the test suite
shime authored
121 LOCAL_GEMS =
122 [
123 ["rack","1.3.2"],
124 ] +
125 RAILS_VERSIONS.collect { |version| ['rails', version] } +
126 [
127 ['sham_rack', nil],
128 ['capistrano', nil],
129 ['sqlite3-ruby', nil],
611e8ea Hrvoje Šimić log messages for sinatra and rack
shime authored
130 ["therubyracer",nil],
131 ["sinatra",nil]
afcd9ca Hrvoje Šimić support rails 3.2.x with the test suite
shime authored
132 ]
133
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
134
13bb3dd Description for vendor_test_gems rake task
Harold Giménez authored
135 desc "Vendor test gems: Run this once to prepare your test environment"
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
136 task :vendor_test_gems do
8294dcd Joe Ferris Restore gem path after vendoring
jferris authored
137 old_gem_path = ENV['GEM_PATH']
138 old_gem_home = ENV['GEM_HOME']
139 ENV['GEM_PATH'] = LOCAL_GEM_ROOT
140 ENV['GEM_HOME'] = LOCAL_GEM_ROOT
afcd9ca Hrvoje Šimić support rails 3.2.x with the test suite
shime authored
141
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
142 LOCAL_GEMS.each do |gem_name, version|
143 gem_file_pattern = [gem_name, version || '*'].compact.join('-')
144 version_option = version ? "-v #{version}" : ''
145 pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}")
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
146 existing = Dir.glob(pattern).first
afcd9ca Hrvoje Šimić support rails 3.2.x with the test suite
shime authored
147 if existing
148 puts "\nskipping #{gem_name} since it's already vendored," +
149 "remove it from the tmp directory first."
150 next
151 end
152
153 command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc --backtrace #{version_option} #{gem_name}"
154 puts "Vendoring #{gem_file_pattern}..."
155 unless system("#{command} 2>&1")
156 puts "Command failed: #{command}"
157 exit(1)
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
158 end
159 end
afcd9ca Hrvoje Šimić support rails 3.2.x with the test suite
shime authored
160
8294dcd Joe Ferris Restore gem path after vendoring
jferris authored
161 ENV['GEM_PATH'] = old_gem_path
162 ENV['GEM_HOME'] = old_gem_home
7df97d7 Joe Ferris Added a test for the installation process
jferris authored
163 end
164
165 Cucumber::Rake::Task.new(:cucumber) do |t|
166 t.fork = true
167 t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
168 end
169
c2e8be4 Joshua Clayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
170 task :cucumber => [:vendor_test_gems]
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
171
e7b7d7a Hrvoje Šimić add all supported frameworks to rake test task
shime authored
172
b4f1d3a Hrvoje Šimić fix typo in Rakefile
shime authored
173 def run_rails_cucumber_task(version, additional_cucumber_args)
a3b34b8 Jon Yurek Return non-zero on cucumber failure.
jyurek authored
174 puts "Testing Rails #{version}"
175 if version.empty?
176 raise "No Rails version specified - make sure ENV['RAILS_VERSION'] is set, e.g. with `rake cucumber:rails:all`"
177 end
178 ENV['RAILS_VERSION'] = version
8213553 Hrvoje Šimić monkeypatch the old rails versions in tests
shime authored
179 cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature features/rails_with_js_notifier.feature"
1a84993 David Be explicit about what cucumber commands we run
dvdplm authored
180 puts "Running command: #{cmd}"
181 system(cmd)
a3b34b8 Jon Yurek Return non-zero on cucumber failure.
jyurek authored
182 end
183
d6376fc Jason Morrison Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
184 def define_rails_cucumber_tasks(additional_cucumber_args = '')
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
185 namespace :rails do
6fbbe2b Joe Ferris Added integration tests for rescuing
jferris authored
186 RAILS_VERSIONS.each do |version|
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
187 desc "Test integration of the gem with Rails #{version}"
c2e8be4 Joshua Clayton WIP: Move gemspec out of Rake task, general reorganization
joshuaclayton authored
188 task version => [:vendor_test_gems] do
b4f1d3a Hrvoje Šimić fix typo in Rakefile
shime authored
189 exit 1 unless run_rails_cucumber_task(version, additional_cucumber_args)
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
190 end
191 end
192
193 desc "Test integration of the gem with all Rails versions"
a3b34b8 Jon Yurek Return non-zero on cucumber failure.
jyurek authored
194 task :all do
195 results = RAILS_VERSIONS.map do |version|
b4f1d3a Hrvoje Šimić fix typo in Rakefile
shime authored
196 run_rails_cucumber_task(version, additional_cucumber_args)
a3b34b8 Jon Yurek Return non-zero on cucumber failure.
jyurek authored
197 end
198
199 exit 1 unless results.all?
200 end
1f87891 Joe Ferris Added integration coverage and fixes for older versions of Rails
jferris authored
201 end
202 end
d6376fc Jason Morrison Add rake cucumber:wip:rails* tasks for work-in-progress features
jasonm authored
203
204 namespace :cucumber do
205 namespace :wip do
206 define_rails_cucumber_tasks('--tags @wip')
207 end
208
209 define_rails_cucumber_tasks
210
779c7ac Hrvoje Šimić remove unnecessary shim
shime authored
211 rule /#{"(" + FEATURES.join("|") + ")"}/ do |t|
e7b7d7a Hrvoje Šimić add all supported frameworks to rake test task
shime authored
212 framework = t.name
213 desc "Test integration of the gem with #{framework}"
214 task framework.to_sym do
215 puts "Testing #{framework.split(":").last}..."
216 cmd = "cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features/#{framework.split(":").last}.feature"
217 puts "Running command: #{cmd}"
218 system(cmd)
219 end
220 end
221
222 end
Something went wrong with that request. Please try again.