How to use ActiveRecord fixtures with Namespaced::Models
It’s not obvious how to use ActiveRecord fixture helpers with Namespaced::Models, so here’s the simplest possible way - just a one liner.
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
It’s not obvious how to use ActiveRecord fixture helpers with Namespaced::Models, so here’s the simplest possible way - just a one liner.
Comments
I actually wrote a plugin that will properly use namespaced models with “namespaced” (sub-directoried) fixtures. So:
/test/fixtures/users/admin.yml will properly use the Users::Admin model.
The plugin is a real mess (not really a plugin, I have all of the code in test_helper.rb… I’ll factor into a plugin though) but I’ll try to clean it up and post it to my blog if anybody is interested.
Unfortunately all of my efforts went to waste as I’ve converted all of my projects to RSpec and am now using mocks/stubs. Much better IMO.
Post a comment