Table of Contents
Setting it Up
If you’re a student from Turing School of Software and Design and you’re working on an IC, you’re in the right place.
I wrote this article while I was in mod 2 (2208-BE, ‘sup?), because there were a lot of steps required to setup a project.
Here’s a list that will hopefully help you get from “git clone” to doing the first user story. Good luck!
(* means optional)
The List of Steps:
- Clone the repo to wherever you keep things on your local machine
# this should be happening in your Terminal (or the VSCode Integrated Terminal) > git clone <name-of-the-repository>
- Run the ‘bundle’ command (or ‘bundle install’…they do the same thing)
> bundle
- Read the README.md
# seriously, go take the time to read the README.md....
- Review the existing database schema in the “db/schema.rb” file
- *Open the schema file, select all, and copy; Literally the entire file
- *Go to the FREE website at www.dbdiagram.io and import your schema there, to get a visual representation of the database
- Plan updates to the schema, visually (like, write them with pencil and paper, or update via the website in step 6)
- Create additional models, with their relationships (has_many, belongs_to, has_many through:)
- create the database:
> rails db:create
-
write any migration you may need; For example…..
rails g migration CreateDiscounts percentage:integer threshold:integer merchant:references
- migrate the migration
> rails db:migrate
- Repeat steps 10 and 11, and then migrate any new migrations you write
- Review “/db/schema.rb” for correctness
- *Add the “SimpleCov” gem (don’t forget to bundle or bundle install ….they do the same thing); for most ICs this is already in the Gemfile. To do this quickly run these commands:
# may not need to do this > bundle add simplecov > bundle
-
*Add SimpleCov code to the top of the spec_helper file
# spec/spec_helper.rb require 'simplecov' SimpleCov.start do add_filter "spec/rails_helper.rb" end
- Run your tests to make sure you start with 100% test coverage:
# your command may be different >bundle exec rspec spec/models/
- Add additional tests for model relationships you have added
-
Add Validations
it { should have_many :items }
- Start the user stories
conclusion
There’s still a lot of heavy lifting you have to do to make sure everything is correct, so go through this carefully and let me know if anything is wrong.
cheers!