Monday, January 12, 2009

Restful-Authentication with Cucumber features (Step 2)

Knowing that all the stories that ship with restful-authentication pass, I’m ready to convert to Cucumber features.  The process is actually fairly simple and is described quite clearly on this Cucumber wiki page.  I did have to tweak a couple of the step matchers and create ra_env.rb:

Before do
  Fixtures.reset_cache
  fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures')
  Fixtures.create_fixtures(fixtures_folder, "users")
end
 
# Make visible for testing
ApplicationController.send(:public, :logged_in?, :current_user, :authorized?)

I’d have liked to put this in the support directory but Cucumber loaded it before env.rb, so I put in with the step_definitions.

Once that was done, all that was left was to update authenticated_generator.rb to copy the template features instead of stories.

The result is available from my fork on github.

Enjoy!

No comments :

Post a Comment