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:

  1. Before do  
  2.   Fixtures.reset_cache  
  3.   fixtures_folder = File.join(RAILS_ROOT, 'spec''fixtures')  
  4.   Fixtures.create_fixtures(fixtures_folder, "users")  
  5. end  
  6.    
  7. # Make visible for testing  
  8. 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