18.12.2012 Views

Rails Magazine - Issue 3

Rails Magazine - Issue 3

Rails Magazine - Issue 3

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Finished in 0.43375 seconds.<br />

9 tests, 16 assertions, 0 failures, 0 errors<br />

As a side effect, the form partial change also provided a<br />

working implementation for the edit action, without its own<br />

test. As a simple exercise you can modify the test_edit methods<br />

on your functional test suite for covering that action. If<br />

you are tired of using rake to launch your test suite, you can<br />

take a look at autotest.<br />

Conclusion<br />

Initial requirements for snippety have been fulfilled. If it<br />

this exercise were real, it would be now released to the users<br />

and we would await feedback from them. Maybe they would<br />

like more languages, the addition of line numbers, etc.<br />

What is important is that now you should be more familiar<br />

with TDD. As you have seen, the concept is easy to grasp<br />

and you can use it effectively on your own projects.<br />

Indeed Test::Unit is great but some people are happier<br />

when they can minimize Ruby’s syntactic sugar impact on<br />

tests, still using it to express their tests in a readable language<br />

that is meaningful for the application. Shoulda by Thoughtbot<br />

addresses this issue. You can learn by their nice tutorial.<br />

I can’t close without mentioning RSpec, the original Behaviour<br />

Driven Development framework for Ruby. If you feel<br />

Create a simple code snippet app with <strong>Rails</strong> by Michelangelo Altamore<br />

curious, you could have a look at a great talk by Dave Astels<br />

and David Chelimsky where it is explained what BDD is, and<br />

where it comes from. By the way, if you are interested, The<br />

RSpec Book (beta) has been recently published.<br />

I hope you’ve find it useful and thank you for your time.<br />

Resources<br />

http://github.com/ryanb/nifty-generators/tree/master<br />

http://github.com/ryanb<br />

http://coderay.rubychan.de/<br />

http://railscasts.com/<br />

http://github.com/thoughtbot/shoulda/tree/master<br />

http://github.com/dchelimsky/rspec/tree/master<br />

http://ph7spot.com/articles/getting_started_with_autotest<br />

http://thoughtbot.com/<br />

http://rubyconf2007.confreaks.com/d3t1p2_rspec.html<br />

http://blog.daveastels.com/<br />

http://blog.davidchelimsky.net/<br />

http://www.pragprog.com/titles/achbd/the-rspec-book<br />

Discuss: http://railsmagazine.com/3/2<br />

Looking Up from Below<br />

11<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!