diff --git a/README.md b/README.md index e45eee8..bb4b0f6 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,6 @@ Simple! `require 'seed-fu-mongoid/capistrano'` to have your data get re-seeded on deploy. +### Cucumber/RSpec + +`SeedFuMongoid.seed` diff --git a/lib/seed-fu-mongoid.rb b/lib/seed-fu-mongoid.rb index a795d90..8e1747c 100644 --- a/lib/seed-fu-mongoid.rb +++ b/lib/seed-fu-mongoid.rb @@ -9,6 +9,18 @@ end # punch the duck out of Mongoid::Document +module SeedFuMongoid + class << self + def seed + Dir['db/fixtures/**/*.rb'].each do |file| + puts "== Seed from #{file}" + + load file + end + end + end +end + module Mongoid::Document module ClassMethods def seed_once(*constraints) diff --git a/lib/seed-fu-mongoid/railtie.rb b/lib/seed-fu-mongoid/railtie.rb index 11d2163..20efc46 100644 --- a/lib/seed-fu-mongoid/railtie.rb +++ b/lib/seed-fu-mongoid/railtie.rb @@ -4,11 +4,7 @@ module SeedFuMongoid namespace :db do desc "Load seed data from db/fixtures" task :seed_fu => :environment do - Dir['db/fixtures/**/*.rb'].each do |file| - puts "== Seed from #{file}" - - load file - end + SeedFuMongoid.seed end end end