Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #280 from andrii/set_fixture_replacement
Browse files Browse the repository at this point in the history
Set Fabrication as a fixture replacement in Rails
  • Loading branch information
paulelliott committed May 14, 2016
2 parents f5f5234 + ff2fd77 commit b1eb869
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fabrication.rb
@@ -1,3 +1,5 @@
require 'fabrication/railtie' if defined?(Rails)

autoload :Fabricate, 'fabricate'

if defined?(Rake)
Expand Down
17 changes: 17 additions & 0 deletions lib/fabrication/railtie.rb
@@ -0,0 +1,17 @@
module Fabrication
class Railtie < Rails::Railtie
initializer 'fabrication.set_fixture_replacement' do
# Rails 3.0.1 and up uses `app_generators`
generators =
if config.respond_to?(:app_generators)
config.app_generators
else
config.generators
end

unless generators.rails.has_key?(:fixture_replacement)
generators.fixture_replacement :fabrication
end
end
end
end

0 comments on commit b1eb869

Please sign in to comment.