This rails class was originally concieved and implemented by Blazing Cloud Team & Sarah Allen.
This class focuses on giving begining rails users exposure to the basic concepts that are working in rails in a test-oriented way.
Behaviour Driven Development or BDD is a style that intends to concern itself around the specification and design of test cases that focus on a specific ability of an object or system. *BDD-style thinking* is often constructed in terms of some 'actor' that has some kind of 'behaviour' under certain 'conditions'.
Example of tests used in class:
- Adddress with valid attributes should create a new instance
- Address witout valid attributes should require a street to create a new instance
- Address witout valid attributes should require a street to city a new instance
- Address witout valid attributes should require a street to zip a new instance
Much of class will involve walking through the instructions in the book. The first 24 pages will orient the user to rails generators, rails views, controllers and model basics. On page 25 we will be using the provided files in the code repository to experience a Test Driven approach to Rails.
Page 5
- Installing the correct version of rails for these notes is as follows
- gem install rails -v 3.2.8 --no-rdoc --no-ri
Page 10
- Heroku no longer supports SQLite and so the gemfile will need to be modified
- Instead of | gem 'sqlite3' | Replace with :
- group :development,:test do; gem 'sqlite3'; end
- Additionally add the following to have a db on heroku
- group :production do ; gem 'pg'; end
- Additonally you will need to 'bundle without production' as follows:
- bundle --without production
- And then check in code
- git add -u && git commit -m 'updated gemfile for heroku to use pg and local to use sqlite'
- And push to heroku
- git push heroku master
- Instead of | gem 'sqlite3' | Replace with :
Page 13
- Unless you are using OSX you will need to comment out a line in your bundler for a javascript engine.
- Uncomment the following line in your gemfile
- # gem 'therubyracer', :platforms => :ruby
- Then run 'bundle' to install gem and update Gemfile.lock
- bundle
- Uncomment the following line in your gemfile
Page 25
- You will need to use a compatability version of rspec to be compatable with the pre-created spec files
- Instead of | gem "rspec-rails" | Replace with:
- gem "rspec-rails", "2.99"
- Instead of | gem "rspec-rails" | Replace with:
- The text rendering is confusing please note the following
- rails generate rspec:install
- mdkir spec/models
- Where it says "create a file" you can use the file in the rails_lessons repository
- cp ./rails_lessons/1_models/person_spec.rb spec/models
- Then run rake spec to see first errors - use page 24 as a reference to fix errors
- rake spec
Page 35 & 36
- After reading this take a look at 2_controller/controllers/people_controllers_spec.rb for examples of use.
- this spec will pass if you install it in the roster app after running the person scafold command.