Musician, Ruby on Rails Entusiast, Composer, Programmer and Lover of Hot Sauce

Using Authlogic with Cucumber

Posted: June 27th, 2010 | Author: mindtonic | Filed under: Cucumber, Ruby, Shoulda, Testing | Tags: , , , , | No Comments »

I have been working with Cucumber lately and have been retrofitting one of my main projects Sumuv.com with appropriate behavioral tests.  We have a fully functional test suite written with Shoulda and Test::Unit, so I am not particularly interested in translating the unit and functional tests to RSpec.


This is the vegetable you are looking for.

I figured that since the Cucumber BDD tests are completely different than the Shoulda unit and functional tests, I could just slip my Cucumber steps right on in.  It does seem a little strange to be writing the functional tests in Test::Unit and the behavioral steps in RSpec.  In the future I will probably follow the Shoulda train and move to RSpec exclusively, but I am enjoying the differences in the two platforms on this particular retrofit.

While I am mentioning the Shoulda train, I really enjoyed Thoughtbot’s post “This should_change Your Mind“.  Their very simple explanations of the difference between behavioral testing and functional testing created a clear distinction in my mind.  It was the golden nugget of wisdom I had been looking for.

I have been a big fan of Binary Logic’s Authlogic gem for handling site authentication and user sessions.  I love the clean interface and versatility.  A lot of forethought went in to make this an elegant interface on top of some pretty robust and secure code.

As a result of this work, I have created a set of Authlogic behavior steps to use in my Cucumber tests.  These steps cover most of your basic functionality and provide some helper functions that you can use in your other step definitions.  The Cucumber feature definitions cover the major elements of authentication: logging in, logging out and the presence of a UserSession.

I will continue to improve the quality and coverage of these features.  I plan to include a set of features to cover user registration.  I offer this here because I find it useful for my other projects.  If you find it helpful too, please let me know!

http://github.com/mindtonic/AuthLogic-Cucumber-Steps


Webrat for integration testing

Posted: August 17th, 2009 | Author: mindtonic | Filed under: Uncategorized | Tags: , , , | No Comments »

Webrat:

Integration Testing:


should_eventually write this test

Posted: August 17th, 2009 | Author: mindtonic | Filed under: Uncategorized | Tags: , | No Comments »

One thing I liked about rspec was the ability to define tests that you had not yet written. That way you could remind yourself when running the test suite that there are things still to do. Previously in Shoulda, I have been writing these kinds of tests in all caps and using “assert false” to trigger failure and remind me of future work. Turns out there is a nifty way to do it with Shoulda. (I should have guessed there would be!)

should_eventually "do something"

#or just leave off the block
should "do something"

Thanks to BlenderBox for bringing this to my attention while researching Shoulda integration testing.


Unit Testing Object Oriented PHP5 Code

Posted: July 1st, 2009 | Author: mindtonic | Filed under: PHP Testing | Tags: , , , , | No Comments »

I have been doing a lot for work with testing and development in Ruby. This has lead me to want to find an option to write Unit Tests for my own PHP based Content Management System, Shabda. It would be a very wise move to make sure that the core system files function exactly as expected. I will update this blog post as I go along.

My research has yielded two possible testing options:

SimpleTest

Other blogs with more information: http://vailo.wordpress.com/2008/07/03/php-unit-test-test-driven-development/