Testing http requests with VCR

Ruby Gem: VCR

VCR on Github

When working on Discuss-it the team found that testing our API http requests slowed down our testing in a big way and sometimes returned inconsistent results.  Since we didn’t want to test the reliability of our external dependencies VCR was the perfect tool to step in between our http request and our test.

What it does is create a ‘cassette’ file in your spec folder which records the first response to your http request and then on ‘replay’ when you rerun your tests it uses the cassette data instead.  If your tests are http request heavy you’ll be able to test how the requests are handled much more consistently with VCR.

 

 

 

Rails app the Second

A new group project is well underway already: a site that searches out discussions for articles and gives you back links.  We’re making a few Ajax calls and parsing some of the data and feeding it back to the user.  This version doesn’t explicitly need Rails to run an could probably have functioned just as well using Sinatra (i’ll post a little more on why I like Sinatra soon), but its a good exercise in working with the rails filesystem and dealing with its idiosyncrasies.  You should see the final website version of the app posted on the portfolio page very soon.

Step two is to wrap it in Javascript and make it into an site pluggable button, but one thing at a time!

We’re using a lot of cool little gems that i’ll write a little bit about in the next few days, so stick around.

First Rails App

At this point it appears i’ve got a few “first” apps in progress.  One from Hartl’s Ruby on Rails Tutorial and the other a group project.  My group consists of Erica and Lucas from the current Portland Code School cohort.  We’re building a discussion finder, which takes a URL and spits out a discussion about that particular URL on one or more sites.

I’m pretty excited about having a functioning rails app under my belt! I’ll throw it up in the portfolio soon.

Rails against the machine

The dive into Rails has begun during week 5 at Portland Code School.  Sinatra, ActiveRecord and other complimentary technologies are filtering in to our brains.  So far i’m enjoying the division of labor between the different components of web apps we’ve looked at.  I may just be grokking a little more than I used to.

We’ll be plodding through a lot of different resources in the coming days including:

Ruby on Rails Tutorial

Treehouse Rails track

Rails for Zombies

My body is ready.

Examine closely

There will be reading comprehension questions following this excerpt.

Project based testing versus question testing:

We’ve had both, but I think its more difficult to demonstrate mastery when you are just regurgitating memorized terms or not directly applying the concepts you are supposed to be demonstrating knowledge of.

An open ended project can quickly swallow you whole, but when you are given clear goals you can scale and plan a project that matches the scope of the guidelines.

I have definitely preferred the project based version of exams so far because they allow me to demonstrate to myself that I know the topics and have a work sample when i’m finished.  Whereas working on a much smaller code example won’t be as useful when its just sitting around by itself to show I can manage the syntax.  Project exams have the added benefit of grading doubling as a code review which means you get more valuable and applicable feedback.

In “Examine Closely” the author compared to different approaches to exams.  List the two methods and three key differences.

Discuss the effect of Plato’s Theory of Forms on testing in education.

Extra credit: In less than three tries and with no references spell the Author’s full name correctly.

Sleep Hygiene

Or lack thereof…

We were assigned 10 hours of sleep before our first exam and that is the last time I managed more than 8 hours of sleep in this program.

I need a better nights rest for memory and retention, mood, and keeping my brain generally spongy, pliable and absorbent.  So far just going to bed at the right time has failed.

http://sleepyti.me/ is something i’ve been experimenting with along with general good sleep hygiene:

  • Don’t sleep in the same place you work
  • Get enough water during the day
  • Meditate before bed
  • Exercise everyday (okay, this one needs some work)
  • Less sugar and caffeine

I can’t seem to eliminate my computer time right before bed and when I do manage it my mind is filled with code (pseudo code really… if I dreamt in syntax I might be a bit better at it by now).

I almost forgot to close those parentheses just now.

Until then:  sudo sleep