-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
executable file
·68 lines (51 loc) · 2.18 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
require 'bundler'
Bundler::GemHelper.install_tasks
ENGINE = "simple_admin"
desc "Creates a sample application using the current Gemfile"
task :sample do
# Cleanup any existing sample and generate the new application
FileUtils.rm_rf("spec/sample")
system "cd spec && rails new sample"
# Include this engine as a plugin (requires rails/init.rb)
FileUtils.mkdir_p("spec/sample/vendor/plugins")
engine_root = File.expand_path(File.dirname(__FILE__))
system "ln -s #{engine_root} spec/sample/vendor/plugins/#{ENGINE}"
# Go to the sample
Dir.chdir "spec/sample"
# Generate our initializer into the sample application
system "rails g #{ENGINE}:install"
system "rails g #{ENGINE}:assets"
# Make a place and a thing
system "rails g scaffold place name:string"
system "rails g scaffold thing name:string happy:boolean age:integer place_id:integer"
# Add relations to the declarations
system "echo 'class Place < ActiveRecord::Base; has_many :things; end;' > app/models/place.rb"
system "echo 'class Thing < ActiveRecord::Base; belongs_to :place; end;' > app/models/thing.rb"
# Manually add a route
puts "Adding test routes..."
routes = File.read("config/routes.rb")
routes.gsub!(/^end$/, "\n\n resources :admins, :controller => 'simple_admin/admin'\nend")
File.open("config/routes.rb", "w") { |f| f.write routes }
# We need testing gems and kaminari and formtastic by default
['kaminari', 'formtastic', 'rspec-rails', 'mocha', 'shoulda', 'factory_girl', 'capybara'].each do |gem|
system "echo 'gem \"#{gem}\"' >> Gemfile"
end
# If we are not on 1.9.x we need fastercsv
system "echo 'gem \"fastercsv\"' >> Gemfile" if RUBY_VERSION =~ /^1.8/
# To work with Rails 3.1.x we need ransack
system "echo 'gem \"ransack\"' >> Gemfile"
# With more gems, comes more bundling
system "bundle"
# Make an admin interface
system "echo 'SimpleAdmin.register :thing do; end' > app/admin/things.rb"
end
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end
task :default => :spec