Created
June 17, 2016 18:58
-
-
Save AhmedNadar/e8e3d9cad7eb8cc66ab2294365c37a01 to your computer and use it in GitHub Desktop.
Get Launching Cheat Sheet provided by RubyThursday.com -- updated 5/21/16
This file contains hidden or 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
1. Open terminal and check versions of Ruby and Rails against production server params or to make sure you are using the most recent stable versions. | |
$ ruby -v | |
$ rvm list | |
$ rvm list known | |
$ rvm install ruby 2.3.1 | |
$ rvm list | |
$ ruby -v | |
$ gem install rails | |
$ rails -v | |
2. Navigate to where you want to create your app. | |
$ cd ~/Sites | |
3. Create new repo/app without unit tests | |
$ rails new {name} -T | |
example: $ rails new ruby_thursday -T | |
or if needing to a specific version of rails: $ rails _4.1.0_ new ruby_thursday -T | |
4. Navigate into new app | |
$ cd ruby_thursday | |
5. Set up git | |
$ git init | |
6. Set up Github and make first commit | |
copy/paste from Github to create remote repo | |
$ git add . | |
$ git commit -m "Initial commit" | |
7. Open app in favorite text editor. | |
$ subl . | |
8. Set Ruby version in Gemfile | |
ruby '2.3.1' | |
9. Review standard gems change any per preferences | |
You need to have Postres installed first -- https://wiki.postgresql.org/wiki/Detailed_installation_guides | |
gem 'pg' | |
10. Set up preferred test and development gems | |
#Option 1: with 'capybara-webkit' -- you need to have QT installed first https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit. | |
group :development, :test do | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'capybara-email' | |
gem 'capybara-webkit' | |
gem 'factory_girl_rails' | |
gem 'faker' #some older RubySnacks may reference 'ffaker' | |
gem 'database_cleaner' | |
gem 'letter_opener' | |
gem 'rspec-rails' | |
gem 'pry' | |
gem 'pry-nav' | |
gem 'pry-rails', '~> 0.3.2' | |
gem 'simple_bdd' | |
gem 'shoulda-matchers' | |
gem 'spring' | |
end | |
#Option 2: with 'selenium-webdriver' | |
group :development, :test do | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'capybara-email' | |
gem 'factory_girl_rails' | |
gem 'faker' | |
gem 'database_cleaner' | |
gem 'letter_opener' | |
gem 'rspec-rails' | |
gem 'pry' | |
gem 'pry-nav' | |
gem 'pry-rails', '~> 0.3.2' | |
gem 'selenium-webdriver' | |
gem 'simple_bdd' | |
gem 'shoulda-matchers' | |
gem 'spring' | |
end | |
11. Install the gems | |
$ bundle | |
12. Edit config/database.yml with preferred database and database names | |
adapter: postgresql | |
development: | |
<<: *default | |
database: db/ruby_thursday_development | |
test: | |
<<: *default | |
database: db/ruby_thursday_test | |
production: | |
<<: *default | |
database: db/ruby_thursday_production | |
13. Create database | |
$ rake db:create | |
14. Install rspec | |
$ rails generate rspec:install | |
15. Edit or create rails_helper.rb | |
#Replace with below for Option 1: with 'capybara-webkit' | |
ENV['RAILS_ENV'] ||= 'test' | |
require File.expand_path('../../config/environment', __FILE__) | |
# Prevent database truncation if the environment is production | |
abort("The Rails environment is running in production mode!") if Rails.env.production? | |
require 'spec_helper' | |
require 'rspec/rails' | |
require 'capybara/rspec' | |
require 'simple_bdd' | |
require 'shoulda/matchers' | |
Capybara.javascript_driver = :webkit | |
ActiveRecord::Migration.maintain_test_schema! | |
RSpec.configure do |config| | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
config.use_transactional_fixtures = true | |
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
config.include SimpleBdd, type: :feature | |
Shoulda::Matchers.configure do |config| | |
config.integrate do |with| | |
with.test_framework :rspec | |
with.library :rails | |
end | |
end | |
config.infer_spec_type_from_file_location! | |
config.filter_rails_from_backtrace! | |
end | |
#Replace with below for Option 2: with 'selenium-webdriver' | |
ENV['RAILS_ENV'] ||= 'test' | |
require File.expand_path('../../config/environment', __FILE__) | |
# Prevent database truncation if the environment is production | |
abort("The Rails environment is running in production mode!") if Rails.env.production? | |
require 'spec_helper' | |
require 'rspec/rails' | |
require 'capybara/rspec' | |
require 'simple_bdd' | |
require 'shoulda/matchers' | |
ActiveRecord::Migration.maintain_test_schema! | |
RSpec.configure do |config| | |
config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
config.use_transactional_fixtures = false | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, :js => true) do | |
DatabaseCleaner.strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.start | |
end | |
config.after(:each) do | |
DatabaseCleaner.clean | |
end | |
config.include SimpleBdd, type: :feature | |
Shoulda::Matchers.configure do |config| | |
config.integrate do |with| | |
with.test_framework :rspec | |
with.library :rails | |
end | |
end | |
config.infer_spec_type_from_file_location! | |
config.filter_rails_from_backtrace! | |
end | |
16. Commit set up | |
$ git add . | |
$ git commit -m "Set up app with development gems, rspec, and pg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment