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.
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.
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
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 :-)
… 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.
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…