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
|
# File 'lib/highgroove_command.rb', line 12
def new(name)
@name = name
run "rails new #{name} --skip-bundle -T -q -d #{options[:database]}"
inside name do
run "git init -q"
gsub_file "Gemfile", /^ *#.*$/, ''
gsub_file "Gemfile", /^ *$\n/, ''
append_to_file "Gemfile" do
<<-EOF
gem 'slim'
group :test, :development do
gem 'rspec-rails'
gem 'factory_girl'
gem 'forgery'
gem 'heroku'
end
group :test do
gem 'capybara'
gem 'launchy'
gem 'database_cleaner'
gem 'capybara-webkit'
gem 'simplecov'
end
EOF
end
if options[:ruby] == 'rvm'
run "rvm 1.9.3-p125 do rvm --rvmrc --create 1.9.3-p125@#{name}"
end
rvm_run "gem install bundler"
rvm_run "bundle install --quiet"
rvm_run "rails g rspec:install"
rvm_run "rails g forgery"
insert_into_file 'spec/spec_helper.rb', "\nrequire 'capybara/rspec'", after: "require 'rspec/autorun'"
gsub_file 'spec/spec_helper.rb', / *# Remove this[^\n]*\n *config\.fixture_path[^\n]*\n\n/m, ''
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures = true/, 'config.use_transactional_fixtures = false'
insert_into_file 'spec/spec_helper.rb', after: "config.infer_base_class_for_anonymous_controllers = false\n" do
<<-EOF
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
EOF
end
append_to_file 'spec/spec_helper.rb', "\nCapybara.javascript_driver = :webkit\n"
prepend_to_file 'spec/spec_helper.rb' do
<<-EOF
require 'simplecov'
SimpleCov.start
EOF
end
append_to_file '.gitignore', "\ncoverage\n.rvmrc"
remove_file 'public/index.html'
remove_file 'README.rdoc'
remove_file 'doc/README_FOR_APP'
gsub_file 'config/database.yml', /username: .*$/, 'username:'
rvm_run 'rake db:create'
end
copy_file "templates/README.md", "#{name}/README.md"
inside name do
rvm_run 'rake db:migrate'
rvm_run 'git add .'
rvm_run 'git commit -m "Initial Commit"'
if options[:host] == 'heroku'
rvm_run "heroku apps:create #{name.gsub(/[^a-z0-9\-]/, '')} -s cedar"
rvm_run 'git push heroku master'
end
end
end
|