inchworm

inchworms

Summer of Coding, one inch at a time...

Red Green Refactor

inchworms - Tue 16 July, 2013, 17:24

Today we watched an excellent video tutorial by PeepCode to learn more about RSpec. It covered:

  • Learning the basic concept of the RSpec testing framework
  • Learning the syntax of RSpec
  • Using Rspec in isolation with a basic Ruby project
  • Understanding the describe and it methods

Some key RSpec syntax:

	expect(thing).to eq 'result'	

And also:

  • Understanding the red/green cycle of development
  • Implementing the first feature of the application
  • Creating a client and giving it a URL
  • Using an HTTP Client app to see what a URL returns when sent a request
  • Fetching an XML feed
  • Parsing the XML of the comments feed
  • Using the let method to simplify setup
  • Using nested describe blocks
  • Organising application code
  • Debugging and fixing errors in RSpec code
  • Parsing extra fields
  • Working with unexpected Unicode input
  • Using trivial examples to catch errors and expose assumptions

You can look at the code on GitHub.

Then we started working on Part 2 of the PeepCode tutorial, which we’ll finish tomorrow.

Oh yeah, we had a yummy lunch at Co.Up with Matt and Urs (and Nabil, Andy, and Hannah)…

salad

…and @bumbledeebee left us a gift!

bubbles

Getting Our Hands Dirty with Tests

inchworms - Mon 15 July, 2013, 17:49

So today, after posting an introduction to ourselves on the RGSoC Blog, we started building another version of our Songs by Nancy app, but this time using Test Driven Development (TDD).

RGSoC Team Hackety Hack wrote a great post last week about the importance of testing. Part of our plan for RGSoC was to learn more about testing within the Sinatra development enviroment. To do this we will (for starters) build our Songs by Nancy app again starting with tests first.

Understanding the importance of TDD is one thing. Knowing what to test for is another. After Matt gave us a few pointers about how we could go about deciding that, we watched a couple of videos, including a tutorial with some basic examples of using Rspec with Sinatra, we started building v3 of our app, starting with some tests.

Everything went okay (and by ‘everything’ we mean a single test) until we wanted to test the content of a view. As usual there was an inordinate amount of mostly fruitless searching online for help. But (also as usual) we eventually found something to help us. We learnt that Sinatra doesn’t respond to the same Rspec methods that Rails does, and that in any case, to test anything on the front-end of our app we would need to use the Capybara gem. Capybara helps test web applications by simulating how a real user interacts with the app (and an app’s views function in response to a user’s interaction, hence the need for Capybara when testing views).

So, it’s been a long day, and now we’re off to our Rubymonsters project group.

capybara

An Invitation Anja Could Not Resist

inchworms - Fri 12 July, 2013, 19:00

Today while Carla met with her DCA supervisor (visting Berlin from Australia), Anja chased some much needed fresh air by accepting Maren’s invitation to sit and work in her garden for the day (Maren, aka @zaziemo, is one of our awesome rubymonsters collegues). Unfortunately the weather did not agree, so they worked in Maren’s comfortable kitchen instead.

Marens kitchen

While snacking on fruits, and without any distractions, Anja was able to get organised and start the first of our tests of the Sinatra app. It tests whether the sites routes are available. It went green!

  def test_root_returns_home
    get '/'
    assert last_response.ok?
  end

On Monday we’ll start with rspec testing by using this tutorial: Tutplus Sinatra Tutorial.

And, after a long and devastating fight during the week trying to deploy our app to Heroku via our iMacs (both running ruby 1.8.7), a fight we didnt win, we agreed to write up the tutorial as a blog post instead and leave the screencasts for a while. We might pick them up again later. As for deploying via mac, if we ever do, we’ll update our Ruby version first. We’re actually pretty happy to get back to Ubuntu :-)

Screencasting Part 3

inchworms - Thu 11 July, 2013, 17:45

… Tutorial Part 3 is still in progress. Issues related to deploying to heroku carried on into the late afternoon. They remain unresolved. We’ll finish editing the bulk of the screencast this evening. Anja will see if she can get heroku deploy working on her machine.

@bioshrimp did a drawing of grumpy Carla. Which we love.

grumpy carla

Screencasting Part 2

inchworms - Wed 10 July, 2013, 18:49

More of the same today, only Anja was the voice over speakerenin this time. Tutorial Part 2 video is below. Files available to download here.


Also: a stop motion video fairy came to visit.


Meanwhile, after a better than expected day in the field (bowling England all out for 215) the Aussies collapsed to 3 wickets down for 39. Something tells me their summer might be one of pain…