Last active
December 28, 2015 19:29
-
-
Save ml242/7550433 to your computer and use it in GitHub Desktop.
Rspec for Rails
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
i.e. RAILS_ENV = (development, test, production) | |
Gemfile: | |
gem "rspec-rails", :group => [:test, :development] | |
gem 'jquery-rails' | |
development: | |
adapter: postgresql | |
encoding: unicode | |
database: <%= File.basename(Rails.root) %>_development | |
pool: 5 | |
host: localhost | |
username: <%= ENV['PG_USERNAME'] %> | |
password: | |
test: | |
adapter: postgresql | |
encoding: unicode | |
database: <%= File.basename(Rails.root) %>_test | |
pool: 5 | |
host: localhost | |
username: <%= ENV['PG_USERNAME'] %> | |
password: | |
production: | |
adapter: postgresql | |
encoding: unicode | |
database: <%= File.basename(Rails.root) %>_production | |
pool: 5 | |
username: <%= ENV['PG_USERNAME'] %> | |
password: | |
command prompt: | |
rails g rspec:install | |
$ rails g model trainer email:string password_digest:string name:string | |
$ rake db:migrate | |
$ RAILS_ENV=test rake db:migrate //creates the table just in the test... rake db:migrate just installs on developement. | |
### after ### | |
> guard init | |
> bundle exec guard | |
source 'https://rubygems.org' | |
gem 'rails', '3.2.14' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'pg' | |
gem "rspec-rails", :group => [:test, :development] | |
gem 'jquery-rails' | |
#Gemfile | |
group :development, :test do | |
gem 'pry-rails' # Causes rails console to open pry | |
# https://github.com/rweng/pry-rails | |
gem 'pry-debugger' # Adds step, next, finish, and continue commands and breakpoints | |
# https://github.com/nixme/pry-debugger | |
gem 'pry-stack_explorer' # Navigate the call-stack | |
# https://github.com/pry/pry-stack_explorer | |
gem 'annotate' # Annotate all your models, tests, fixtures, and factories | |
# https://github.com/ctran/annotate_models | |
gem 'quiet_assets' # Turns off the Rails asset pipeline log | |
# https://github.com/evrone/quiet_assets | |
gem 'better_errors' # Replaces the standard Rails error page with a much better and more useful error page | |
# https://github.com/charliesome/better_errors | |
gem 'binding_of_caller' # Advanced features for better_errors advanced features (REPL, local/instance variable inspection, pretty stack frame names) | |
# https://github.com/banister/binding_of_caller | |
gem 'meta_request' # Supporting gem for Rails Panel (Google Chrome extension for Rails development). | |
# https://github.com/dejan/rails_panel/tree/master/meta_request | |
gem 'rails-erd' # Diagrams your models. NOTE! $ brew install graphviz | |
# https://github.com/voormedia/rails-erd | |
gem 'awesome_print' # Pretty print your Ruby objects in full color and with proper indentation | |
# https://github.com/michaeldv/awesome_print | |
end | |
# Gems used only for assets and not required | |
# in production environments by default. | |
group :assets do | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'coffee-rails', '~> 3.2.1' | |
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | |
# gem 'therubyracer', :platforms => :ruby | |
gem 'uglifier', '>= 1.0.3' | |
end | |
# To use ActiveModel has_secure_password | |
gem 'bcrypt-ruby', '~> 3.0.0' | |
# To use Jbuilder templates for JSON | |
# gem 'jbuilder' | |
# Use unicorn as the app server | |
# gem 'unicorn' | |
# Deploy with Capistrano | |
# gem 'capistrano' | |
# To use debugger | |
# gem 'debugger' | |
########## end gemfile ###### | |
expect(trainer.errors).to have_key(:email) | |
rake db:test:prepare | |
Describe and context are kind of the same, but they differ in when they use them for human readability. | |
Inside Describe, you have contexts which are the state. | |
This is a good place to use the 'let' variable. | |
Describe is at the top of the file and for methods. | |
use Let instead of before to instantiate from a model. | |
#### | |
@outer_namial | |
@inner_anamial | |
it "inner it statement" | |
describe Outer do | |
before(:each) do | |
@outer_animal = Animal.create | |
end | |
it "outter it statement" | |
describe Inner do | |
before(:each) do | |
@inner_anamial = Animal.create | |
end | |
it "inner it statement" | |
end | |
context "the inner context" do | |
end | |
end | |
describe '#recover' <- the # indicates an instance method of the specific monster | |
describe '.recover' <- the . indicates a class method on monsters.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment