Sonntag, 18. September 2011

SFD Münster: PDF reports with Cucumber

By this post, I want to complete my talk on "Executable Specifications using Cucumber" during Software Freedom Day Münster.

Yesterday the JUG Münster and the produktivhaus | Coworking Space organized a local event associated with the world-wide Software Freedom Day. In my opinion, the event was quite a success.
In the course of the afternoon talks, I also took the opportunity. I chose the topic "Executable Specifications using Cucumber". All in all, my was not too bad, I suppose. But one thing bugged me: after delivering my talk (and a small, live-coded example), one participant asked me, what was the special advantage of using Cucumber for writing acceptance tests. Generally, I think that the advantage is the understandability / readability of the feature files. Gherkin (the language in which the features are described) has only minimal syntactical demands. Most of the content is simple prose (and some tables). This is easy to read and understand for business users what facilitates discussions, because they and the developers are nearly instantly able to write new feature specifications, change (and maintain) existing ones etc.
Another pro is the possibility to create PDF reports automatically. This is useful for management information, printing and archiving. I wanted to demonstrate the feature. Unfortunately, there was some kind of problem with the PDF generation mechanism. I was not able to resolve the issue immediately, so I could not prove my argument. I want to make up on this with this post.
When the event was over, I analysed Cucumber's log output. Finally, I found out that Cucumber relies on the Prawn gem to create PDFs. And Cucumber is built against an old version of Prawn, 0.8.4. I had not defined the desired version of the gems in my Gemfile, so Bundler downloaded the most recent version, which is 0.11.1, respectively 0.12. Because obviously the API changed in the meantime, Cucumber terminated untimely. The correct content of the gemfile is:

source :rubygems

gem "cucumber"
gem "capybara", ">=1.1.0"
gem "selenium-webdriver"
gem "rspec", ">=2.6.0"
gem "prawn", "~> 0.8.4"
gem "prawn-layout", "~> 0.8.4"

bundle install
bundle exec cucumber features --format pdf --out report.pdf
finally creates a feasible report:

Keine Kommentare:

Kommentar veröffentlichen