Telling a good story - Rspec stories from the trenches
August 15th, 2008
I’ve been developing multiple systems using Rspec stories for a little while now. There are a lot of great resources to get you started with a taste of what you can do with stories. Some of the resources I found useful where:
- http://peepcode.com/products/rspec-user-stories
- http://blog.davidchelimsky.net/2008/6/16/slides-from-railsconf
- http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
- http://dannorth.net/whats-in-a-story
- http://evang.eli.st/blog/2007/10/8/story-runner-top-to-bottom-screencast
However once I had understood the basic idea I struggled to find practical examples and general guidance on writing real stories. So I’ve collected some of the lessons I’ve learnt along the way with story examples taken from real systems and how I’ve improved them as I learnt. Most examples are from web based applications.
Rspec-rails is a rails plugin which brings the Rspec Ruby Behaviour Driven Development framework to rails along with some rails specific helpers. One of these hugely useful helper functions is:
mock_model(model_class, options_and_stubs = {})
This creates a mock object with the common methods stubbed out. It also allows you to specify other methods you want to stub.
Read the rest of this entry »
Rspec Stories - Keeping Steps Dry
April 30th, 2008
When using Rspec stories you have plain text stories which we call the ’story’ file and the ’story steps’ file that maps the plain text story to programmatic code. Generally you end up with your story files not being DRY. This is not a worry, your stories are the domain specific languages detailing your acceptance/integration tests. Its like saying that your Rails Models are not DRY because they repeat lots of 'has_one'!
Read the rest of this entry »
Funkload Build script
November 23rd, 2007
Funkload is an open source python based unit testing tool. It serves as a good tool for load testing. We can use it to create a unit test which simulates a user browsing through a site. To test load run two simultaneous instances of the unit test and so on scaling up the number of concurrent instances.
Offical Site: http://funkload.nuxeo.org/
I have written a python based Funkload build script which:
- Builds the Funkload configuration for multiple sites
- Uses wget to generate sample of pages for load testing
- Runs load tests
- Builds HTML documentation from test results.