Permalink
Newer
Older
100644 136 lines (116 sloc) 3.51 KB
2
begin
3
Bundler.setup
4
Bundler::GemHelper.install_tasks
6
raise "You need to install a bundle first. Try 'thor version:use 3.1.3'"
9
task :build => :raise_if_psych_is_defined
10
11
task :raise_if_psych_is_defined do
12
if defined?(Psych)
13
raise <<-MSG
14
===============================================================================
15
Gems compiled in Ruby environments with Psych loaded are incompatible with Ruby
16
environments that don't have Psych loaded. Try building this gem in Ruby 1.8.7
17
instead.
18
===============================================================================
19
MSG
20
end
21
end
22
23
require 'yaml'
24
require 'rspec'
25
require 'rspec/core/rake_task'
26
require 'cucumber/rake/task'
28
desc "Run all examples"
29
RSpec::Core::RakeTask.new(:spec) do |t|
30
t.ruby_opts = %w[-w]
31
t.rspec_opts = %w[--color]
32
end
Apr 18, 2011
33
34
Cucumber::Rake::Task.new(:cucumber)
35
36
if RUBY_VERSION.to_f == 1.8
37
namespace :rcov do
38
task :clean do
39
rm_rf 'coverage.data'
40
end
Apr 18, 2011
41
42
desc "Run cucumber features using rcov"
43
Cucumber::Rake::Task.new :cucumber do |t|
Apr 18, 2011
44
t.cucumber_opts = %w{--format progress}
45
t.rcov = true
46
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
47
t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
48
end
Oct 10, 2010
49
50
desc "Run all examples using rcov"
51
RSpec::Core::RakeTask.new :spec do |t|
52
t.rcov = true
53
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
54
t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
55
end
Oct 10, 2010
56
end
57
58
task :rcov => ["rcov:clean", "rcov:spec", "rcov:cucumber"]
Oct 10, 2010
59
end
60
61
namespace :generate do
62
desc "generate a fresh app with rspec installed"
63
task :app do |t|
64
unless File.directory?('./tmp/example_app')
65
sh "rails new ./tmp/example_app --skip-javascript --skip-gemfile --skip-git"
Nov 21, 2011
66
bindir = File.expand_path("bin")
67
if test ?d, bindir
68
Dir.chdir("./tmp/example_app") do
70
sh "ln -s #{bindir}"
71
application_file = File.read("config/application.rb")
72
sh "rm config/application.rb"
73
File.open("config/application.rb","w") do |f|
74
f.write application_file.gsub("config.assets.enabled = true","config.assets.enabled = false")
75
end
79
end
80
81
desc "generate a bunch of stuff with generators"
82
task :stuff do
83
in_example_app "bin/rake rails:template LOCATION='../../templates/generate_stuff.rb'"
84
end
85
end
86
87
def in_example_app(command)
88
Dir.chdir("./tmp/example_app/") do
89
Bundler.with_clean_env do
90
sh command
91
end
92
end
93
end
Mar 26, 2010
95
namespace :db do
96
task :migrate do
97
in_example_app "bin/rake db:migrate"
Mar 26, 2010
98
end
99
100
namespace :test do
101
task :prepare do
102
in_example_app "bin/rake db:test:prepare"
Mar 26, 2010
103
end
104
end
105
end
106
107
desc "run a variety of specs against the generated app"
108
task :smoke do
109
in_example_app "bin/rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
110
end
111
112
desc 'clobber generated files'
113
task :clobber do
114
rm_rf "pkg"
Nov 20, 2011
116
rm_rf "doc"
117
rm_rf ".yardoc"
Apr 8, 2010
120
namespace :clobber do
121
desc "clobber the generated app"
122
task :app do
123
rm_rf "tmp/example_app"
124
end
127
desc "Push docs/cukes to relishapp using the relish-client-gem"
Oct 10, 2010
128
task :relish, :version do |t, args|
129
raise "rake relish[VERSION]" unless args[:version]
130
sh "cp Changelog.md features/Changelog.md"
131
sh "relish push rspec/rspec-rails:#{args[:version]}"
132
sh "rm features/Changelog.md"
Oct 10, 2010
133
end
134
Oct 10, 2010
135
task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]