Bootstrapping My Rails Application

This post details my starting steps with a new Rails project, and is only kept here to remind me of various tasks that I, generally, like to do at this time. Many of these steps might be redundant or even, obsolete by the time you lay yours eyes on this post :)

Install Rails
1
rails new my_app -T -d mysql -j jquery
Initialize a git repository
1
2
3
4
5
cd my_app
git flow init -d # initialize git work-flow
git add .
git commit -am "Installed Rails"
git flow feature start prepare_base
Create a RVM configuration file
1
rvm use 1.9.3@rails --rvmrc
Add some starting gems to Gemfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
gem 'haml'
# gem 'kaminari'
# gem 'devise'
# gem 'capistrano'
# gem 'unicorn'

group :test, :development do
  gem 'turn'
  gem 'haml-rails'
  gem 'rspec-rails'
  gem 'cucumber-rails'
  gem 'factory_girl_rails'
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'database_cleaner'
  gem 'guard-rspec'
  gem 'guard-cucumber'
  # gem 'guard-unicorn'
  gem 'ruby_gntp'
  gem 'minitest'
  gem 'launchy'
end
Run Bundle Install
1
bundle install
Add database settings in config/database.yml
1
rake db:create:all
Change Home Page
1
2
3
4
rails generate controller home index
rm -rf public/index.html
find . -type f -iname "*.erb" -delete # remove all erb files since we are using haml
# add 'root :to => "Home#index"' in config/routes.rb
Lets, make some generations, huh.
1
2
3
rails generate rspec:install
rails generate cucumber:install --capybara
guard init rspec && guard init cucumber
Make some changes to the features/support/env.rb file:
1
2
3
4
5
6
7
8
9
10
require 'cucumber/rails'
require 'capybara/rails'
require 'capybara/cucumber'
require 'capybara/session'
require "factory_girl/step_definitions"
Capybara.default_selector  = :css
Capybara.javascript_driver = :webkit
ActionController::Base.allow_rescue = false
DatabaseCleaner.strategy = :transaction
Cucumber::Rails::Database.javascript_strategy = :truncation
Lets, add some Cucumber Tests (features/test.feature file):
1
2
3
4
5
6
7
8
Feature: Testing Configuration
  In order to have a base for my new application
  As a developer
  I want to test the configuration settings for this application

  Scenario: Test Home Page
    Given I am on the home page
    Then  I should see "Home#index"
And, the corresponding steps in features/step_definitions/test_steps.rb file:
1
2
3
4
5
6
7
Given /^I am on the home page$/ do
  visit "/"
end

Then /^I should see "([^"]*)"$/ do |text|
  page.should have_content text
end
Open a iTerm2 tab each for the following processes:
1
2
3
4
5
6
# default tab
guard
tail -fn0 log/test.log
rails console
tail -fn0 log/development.log
rails server
Merge our feature into development
1
2
git commit -am "finished with preparing base"
git flow feature finish prepare_base
- by Nikhil Gupta

Comments

Copyright © 2015 - Nikhil Gupta - Powered by Octopress