Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Forked from anonymous/Gemfile
Last active December 23, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm23/6678227 to your computer and use it in GitHub Desktop.
Save jasonm23/6678227 to your computer and use it in GitHub Desktop.
Rails Template (target ver.3.2.14) - Slim + Coffee + Sass + Bootstrap + Markdown (views and partials as name.html.md) and TDD/BDD with Guard/Spork and RSpec; FactoryGirl; Capybara; Poltergeist (PhantomJS) and nice HTML5 Test reports via rspec-formatter-webkit. (-o tmp/spec_results.html) + Syntax Highlighting, Rails Entity Diagramming (railsERD) …
# Remove unnecessary files that rails creates for us.
remove_file "public/index.html"
remove_file "public/images/rails.png"
remove_file "public/javascripts"
empty_directory "public/javascripts"
create_file "public/javascripts/application.js"
gem_group :assets do
gem 'twitter-bootstrap-rails'
gem 'less'
gem 'less-rails'
gem 'therubyracer'
end
gem 'markdown-rails'
gem "redcarpet"
gem 'slim'
gem 'slim-rails'
gem 'simple_form'
gem 'jquery-rails'
gem 'thin'
gem_group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'seed_dump'
gem 'yaml_db'
gem 'rails-erd'
gem 'meta_request'
gem 'guard-spork'
gem 'guard-rspec'
gem "rails3-generators"
end
gem_group :development, :test do
gem 'rspec-rails'
gem 'spork-rails'
gem 'factory_girl'
gem 'factory_girl_rails'
gem 'poltergeist'
gem 'faker'
gem 'capybara'
gem 'syntax'
gem 'rspec-formatter-webkit', :git => "https://github.com/jasonm23/rspec-formatter-webkit.git"
gem 'launchy'
end
application do
<<-RUBY
config.generators do |g|
g.test_framework :rspec, :fixture => false
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
g.assets false
g.helper false
end
RUBY
end
# Bundle install
inside app_name do
run 'bundle install'
end
# setup the javascript
remove_file "public/javascripts/rails.js"
get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery.js"
get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "public/javascripts/jquery-ui.js"
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
# Generators
generate "rspec:install"
generate "bootstrap:install"
# RSpec: Capybara support
create_file "spec/support/capybara.rb", <<-RUBY
require 'capybara/rspec'
require 'capybara/rails'
require 'capybara/poltergeist'
include Capybara::DSL
Capybara.javascript_driver = :poltergeist
RUBY
create_file "spec/requests/home_spec.rb", <<-RUBY
require 'spec_helper'
describe 'visiting the homepage' do
before do
visit '/'
end
it 'should have a body' do
page.should have_css('body')
end
end
RUBY
# RSpec: focus filter
# Adding focus filter to RSpec so we can choose the spec that
# will be run (see http://asciicasts.com/episodes/285-spork)
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do
<<-RUBY
# Adding focus filter to RSpec so we can choose the spec that
# will be run (see http://asciicasts.com/episodes/285-spork)
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
config.include FactoryGirl::Syntax::Methods
RUBY
end
# DeepStruct - Quick helper for working with deep hashes as dot syntax objects
inject_into_file 'spec/spec_helper.rb', :after => "require 'rspec/autorun'\n" do
<<-RUBY
require 'ostruct'
class DeepStruct < OpenStruct
def initialize(hash=nil)
@table = {}
@hash_table = {}
if hash
hash.each do |k,v|
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
@hash_table[k.to_sym] = v
new_ostruct_member(k)
end
end
end
def to_h
@hash_table
end
end
RUBY
end
# RSpec: Removing ActiveRecord fixtures support
gsub_file 'spec/spec_helper.rb', 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', '# config.fixture_path = "#{::Rails.root}/spec/fixtures"'
# Spork https://github.com/sporkrb/spork-rails
run 'bundle exec spork rspec --bootstrap'
# Guard https://github.com/guard/guard-spork
# https://github.com/guard/guard-rspec
# Guard-spork set to load before spork and then rspec:
run 'bundle exec guard init spork'
run 'bundle exec guard init rspec'
# Set default formatter to docs
# Adding additional webkit formatter
# Adding --drb so guard uses Spork
gsub_file 'Guardfile', "guard 'rspec' do", "guard 'rspec', :version => 2, :cli => '--color -f d -rrspec/core/formatters/webkit -f RSpec::Core::Formatters::WebKit -o tmp/spec_results.html --fail-fast --drb ' do"
# Setting libnotify as notification library
inject_into_file 'Guardfile', "notification :libnotify\n\n", :before => /^guard 'spork'.*/
# FactoryGirl reloading each tests run
inject_into_file 'spec/spec_helper.rb', " FactoryGirl.reload\n", :after => "Spork.each_run do\n"
inject_into_file 'spec/spec_helper.rb', "require 'factory_girl'\n", :after => "require 'rubygems'\n"
git :init
git add: "."
git commit: "-a -m 'Initial commit'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment