-
-
Save archfear/403411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file 'Gemfile', <<-GEMS | |
source 'http://gemcutter.org' | |
gem "rails", "3.0.0.beta3" | |
gem "bson_ext" | |
gem "mongoid", "2.0.0.beta4" | |
gem "haml", "3.0.0.rc.2" | |
gem "compass", "0.10.0.rc4" | |
gem "inherited_resources" | |
group :test do | |
gem "rspec-rails", "2.0.0.beta.8" | |
gem "capybara" | |
gem 'database_cleaner' | |
gem 'cucumber-rails', :git => 'git://github.com/aslakhellesoy/cucumber-rails.git' | |
gem 'test-unit' #https://rspec.lighthouseapp.com/projects/16211/tickets/292 | |
gem 'machinist_mongo', :require => 'machinist/mongoid' | |
gem 'faker' | |
end | |
GEMS | |
# Bundle | |
run 'bundle install --relock' | |
# Initialize HAML and Compass | |
run 'bundle exec haml --rails .' | |
run 'bundle exec compass create . --using blueprint --app rails --sass-dir app/stylesheets --css-dir public/stylesheets' | |
run "sass-convert --from sass2 --to scss --recursive app/stylesheets" | |
run 'script/rails plugin install git://github.com/koppen/hassle.git' # for heroku | |
# Overwrites database.yml | |
file 'config/database.yml', <<-CODE | |
# Using MongoDB | |
CODE | |
file 'lib/tasks/mongo.rake', <<-RAKE | |
namespace :db do | |
namespace :test do | |
task :prepare do | |
# Stub out for MongoDB | |
end | |
end | |
end | |
RAKE | |
# Initialize testing suite | |
run 'script/rails g rspec:install' | |
run 'script/rails g cucumber:skeleton --rspec --capybara' | |
run 'script/rails g mongoid:config' | |
file 'features/support/blueprints.rb', <<-EOF | |
require 'sham' | |
require 'faker' | |
EOF | |
file 'features/support/hooks.rb', <<-HOOK | |
Before { Sham.reset } | |
HOOK | |
file 'features/step_definitions/model_steps.rb', <<-RB | |
Given /^a (.+) with (.+) "([^\"]*)"$/ do |model,attribute,value| | |
model.camelize.constantize.make attribute.dasherize => value | |
end | |
RB | |
# Remove default javascript files and initialize jQuery in application.js | |
run "rm public/javascripts/*.js" | |
run "curl -L http://github.com/rails/jquery-ujs/raw/master/src/rails.js > public/javascripts/rails.js" | |
# Add a haml layout with google's jQuery | |
file "app/views/layouts/application.haml", <<-HAML | |
!!! 5 | |
%html | |
%head | |
= csrf_meta_tag | |
= stylesheet_link_tag 'screen.css', :media => 'screen, projection' | |
= stylesheet_link_tag 'print.css', :media => 'print' | |
/[if lt IE 8] | |
= stylesheet_link_tag 'ie.css', :media => 'screen, projection' | |
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' | |
= javascript_include_tag 'application.js' | |
%body | |
= yield | |
HAML | |
file 'public/javascripts/application.js', | |
%q|jQuery(function () { | |
}); | |
| | |
config = <<-CONFIG | |
config.generators do |g| | |
g.orm :mongoid | |
g.template_engine :haml | |
g.test_framework :rspec, :fixture => false | |
end | |
CONFIG | |
inject_into_file 'config/application.rb', "#{config}", :after => "# end\n", :verbose => true | |
gsub_file 'features/support/env.rb', "require 'cucumber/rails/active_record'", "# require 'cucumber/rails/active_record'" | |
gsub_file 'features/support/env.rb', "Cucumber::Rails::World.use_transactional_fixtures = true", "# Cucumber::Rails::World.use_transactional_fixtures = true" | |
gsub_file 'config/application.rb', 'require "active_resource/railtie"', '# require "active_resource/railtie"' | |
gsub_file 'config/application.rb', 'require "rails/test_unit/railtie"', '# require "rails/test_unit/railtie"' | |
gsub_file 'config/application.rb', 'require "active_record/railtie"', '# require "active_record/railtie"' | |
gsub_file 'config/application.rb', 'Bundler.require(:default, Rails.env)', 'Bundler.require(Rails.env, :default)' # To be able to load machinist/mongoid before mongoid itself | |
# Remove index.html, application.html.erb and rails.png | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm app/views/layouts/application.html.erb" | |
# Remove test directory since we're not using test/unit | |
run "rm -rf test" | |
readme = <<-README | |
=============================================================================== | |
Phew! All work done. | |
* Your application is configured to use Mongoid, HAML/SASS, | |
Compass with blueprint, rSpec, Cucumber, Capybara, Machinist and jQuery. | |
SCSS, not SASS stylesheets are being used. | |
* Gems are locked. After modifying your Gemfile, run bundle install --relock | |
* Define machinist blueprints for cucumber in features/support/blueprints.rb | |
* You can see all the included generators by 'rails generate'. | |
* The MongoDB databases are prefixed by your application's name. | |
* jQuery 1.4.2 (via google cdn) and its Rails helpers are in public/javascripts. | |
* ActiveRecord is not being used. If you want to use it, uncomment the following | |
line in application.rb: | |
require "active_record/railtie" | |
and these lines in features/support/env.rb: | |
require 'cucumber/rails/active_record' | |
Cucumber::Rails::World.use_transactional_fixtures = true | |
Get coding! | |
=============================================================================== | |
README | |
puts readme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very cool, thanks!
Just a fix, you need to remove line 3 from config/application.rb, and put
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
to don't load active record