T-15 to Course Start

Rails Tutorial Continued

  • The initial rails new appname  generated a layout file
  • again, tests are added into the /spec/requests/ directory
    • this time, we use a have_selector method (with 2 args in this case), a check for an HTML element with some given content
      • we can check in the 'title' tag that,  :text => "this text should be in the title"
      • or, we can check specifically in the h1 tag that the :text => "header" is present
      • substrings will work in this specific case, don’t need an exact match, but it is case-sensitive
  • Running tests
    • decided to alias be='bundle exec' in ~/.bash_profile
    • let(:this_is_the_signal) { "String" }  can be used as an RSpec helper that will insert the string or block of code that you specify elsewhere into a spec
  • provide(:label, 'String') is a Rails function that associates a string with a label, calling yield(:label) later will insert the string
    • goes before the <!doctype html>
  • incorporating application.html.erb in app/views/layouts
    • whenever a view’s html.erb file is rendered, it is inserted in the place of the <%= yield %> sign in this file
    • this file also specifies the application’s css stylesheet and javascript
  • Failing to Installing PostgreSQL
    • Downloaded the installer, which was an application that I dragged into my ‘Applications’ folder and ran
    • changed my Rails app’s Gemfile to include : gem 'pg', '0.12.2'
    • changed my Rails app’s /configuration/database.yml file according to this site, just the development: section
    • could never get bundle exec rake db:create or db:migrate to work, so gave up, left the install app file there, did a git reset --hard hash#here to change working directory to immediately before I decided to try to migrate.
      • As of now, I don’t know enough to fill in the gaps of the many partial troubleshooting tips on the web for the mess of problems that popped up
      • But maybe, just maybe, the problem might of been that I didn’t, but needed to create a postgreSQL user? No matter what I did to my PATH, which psql returned /usr/bin/psql
  • Tests inside sublime text with Ruby Tests work remarkably well!
    • Command-Shift-R: run a single test
      • on either an it block or a describe block
    • Command-Shift-E: run the last test(s)
    • Command-Shift-T: run all the tests in current file
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s