.rails_aliases
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
export EDITOR=subl | |
export PGHOST=127.0.0.1 | |
#export NOKOGIRI_USE_SYSTEM_LIBRARIES=true | |
function rails_new() { rails new $1 && cd $1 && git init && git add . && git commit -m 'Initial commit'; } | |
alias migrate='rake db:migrate && rake db:rollback && rake db:migrate' | |
function rebuild_db_and_test() { rake db:drop && rake db:create && rake db:migrate && rake db:test:prepare && rspec spec; } | |
function rails_pg() { | |
rails new $1 -T -B --database=postgresql | |
cd $1 | |
# setup rails filesystem | |
echo $1 > .ruby-gemset | |
echo ruby-2.0 > .ruby-version | |
# configure postgres | |
echo /config/database.yml >> .gitignore | |
mv config/database.yml config/database.example.yml | |
sed "s/username: "$1"/username: /g" config/database.example.yml > config/database.yml | |
rake db:create | |
remove_turbolinks | |
add_rails_gems | |
cd .. && cd $1 | |
bundle | |
cd .. && cd $1 | |
rails generate rspec:install | |
# save progress | |
git init | |
git add . | |
git commit -m 'initial commit' | |
subl . | |
} | |
function add_rails_gems() { | |
echo " | |
#gem 'acts-as-taggable-on' | |
#gem 'carrierwave' | |
#gem 'devise' | |
#gem 'kaminari' | |
#gem 'ransack' | |
#gem 'simple_form' | |
#gem 'state_machine' | |
#gem 'stringex' | |
group :test, :development do | |
gem 'capybara' | |
#gem 'factory_girl' | |
gem 'factory_girl_rails' | |
gem 'launchy' | |
gem 'pry-rails' | |
gem 'quiet_assets' | |
gem 'rspec-rails' | |
gem 'shoulda-matchers' | |
gem 'valid_attribute' | |
end | |
" >> Gemfile | |
} | |
function add_bootstrap3() { | |
cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap-theme.min.css vendor/assets/stylesheets/ | |
cp ~/Dropbox/launch/bootstrap3.0.0/css/bootstrap.min.css vendor/assets/stylesheets/ | |
cp ~/Dropbox/launch/bootstrap3.0.0/js/bootstrap.min.js vendor/assets/javascripts/ | |
sed -i '' '$d' app/assets/stylesheets/application.css | |
echo " *= require bootstrap.min\n *= require bootstrap-theme.min\n */" >> app/assets/stylesheets/application.css | |
echo "//= require bootstrap.min" >> app/assets/javascripts/application.js | |
} | |
function remove_turbolinks() { | |
sed -i '' '/turbolinks/,/^$/d' Gemfile | |
sed -i '' '/turbolinks/d' app/assets/javascripts/application.js | |
sed -i '' 's@, "data-turbolinks-track" => true@@' app/views/layouts/application.html.erb | |
} | |
function add_foundation() { | |
echo " | |
gem 'compass-rails' | |
gem 'zurb-foundation', '~> 4.0.0' | |
" >> Gemfile | |
bundle | |
rails g foundation:install | |
} |
I suppose we might as well just use factory_girl_rails, since it requires factory_girl as a dependency.
An earlier version of this script removed the following lines from application.html.erb:
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
This has been corrected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without using factory_girl_rails, you have to do a bit of extra configuration (at least I did) to be able to use factories in your spec files.
sed -i '' '5a
require '''factory_girl'''
FactoryGirl.find_definitions
' spec/spec_helper.rb