-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
127 lines (109 loc) · 4.16 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# encoding: UTF-8
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/test/rails/config/environment")
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
namespace :db do
namespace :test do
task :prepare do
ActiveRecord::Base.configurations = Rails::Application.config.database_configuration
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate("#{File.dirname(__FILE__)}/test/rails/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
desc "Remove the test database"
task :drop do
require 'pathname'
config = Rails::Application.config.database_configuration['test']
path = Pathname.new(config['database'])
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
FileUtils.rm(file)
end
desc "Reset the test database and prepare it through scripts in db/migrate"
task :reset => [:drop, :prepare]
end
end
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'HumpyardForm'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('doc/**/*.rdoc', 'lib/**/*.rb', 'app/*/humpyard_form/**/*.rb')
rdoc.rdoc_files.exclude('lib/generators/**/templates/**/*.rb')
end
begin
require 'rspec'
require 'rspec/core/rake_task'
Rspec::Core::RakeTask.new(:spec)
namespace :spec do
desc "Run specs to generate coverage"
Rspec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov = true
spec.rcov_opts = %[--exclude "core,expectations,gems/*,spec/resources,spec/spec,spec/spec_helper.rb,/Library/Ruby/*,config/*" --text-summary --sort coverage]
end
end
task :spec => [:'db:test:reset']
rescue
task :spec do
abort 'Spec is not available. In order to run cucumber, you must: sudo gem install rspec'
end
end
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:cucumber)
namespace :cucumber do
desc "Run cucumber to generate coverage"
Cucumber::Rake::Task.new(:rcov) do |cucumber|
cucumber.rcov = true
cucumber.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/,test\/ --aggregate coverage.data}
cucumber.rcov_opts << %[-o "coverage"]
end
task :cucumber => [:'db:test:reset']
end
rescue LoadError
task :cucumber do
abort 'Cucumber is not available. In order to run cucumber, you must: sudo gem install cucumber'
end
end
desc "Run RSpec and Cucumber tests"
task :test => [:spec, :cucumber]
task :default => :test
desc "Run both rspec and cucumber tests to generate aggregated coverage"
task :rcov do |t|
rm "coverage.data" if File.exist?("coverage.data")
Rake::Task['spec:rcov'].invoke
Rake::Task["cucumber:rcov"].invoke
`open #{File.dirname(__FILE__)}/coverage/index.html`
end
spec = Gem::Specification.new do |s|
s.name = "humpyard_form"
s.summary = %Q{HumpyardForm is a Rails form builder}
s.description = %Q{HumpyardForm is an form builder for Rails 3 applications. It is developed as part of the humpyard cms}
s.email = '[email protected]'
s.homepage = 'http://humpyard.org/'
s.authors = ['Sven G. Broenstrup', 'Andreas Pieper']
s.files = Dir["{lib}/**/*", "{app}/*/humpyard_form/**/*", "{config}/locales/*", "{compass}/**/*", "VERSION", "README*", "LICENCE", "Gemfile"]
s.version = ::File.read(::File.join(::File.dirname(__FILE__), "VERSION")).strip
s.add_dependency 'builder'
s.add_dependency 'rails', '>= 3.0.0'
s.add_dependency 'haml', '>= 3.0.0'
s.add_dependency 'compass', '>= 0.10.0'
s.add_dependency 'globalize3', '>= 0.0.7'
end
Rake::GemPackageTask.new(spec) do |pkg|
end
desc "Create a stand-alone gemspec"
task :gemspec do
open("#{spec.name}.gemspec", "w") do |f|
f.puts "# Generated by rake\n# DO NOT EDIT THIS FILE DIRECTLY\n"
f.puts spec.to_ruby
end
end
task :gem => [:gemspec]
desc "Install the gem #{spec.name}-#{spec.version}.gem"
task :install do
system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
end
task :install => [:gem]