From acaeaf308a071d9892f8d555be0697c45558ef4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 27 Jun 2009 14:03:35 +0200 Subject: Add a fixture replacement hook to TestUnit model generator. --- railties/lib/generators/test_unit/model/model_generator.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'railties/lib/generators/test_unit/model/model_generator.rb') diff --git a/railties/lib/generators/test_unit/model/model_generator.rb b/railties/lib/generators/test_unit/model/model_generator.rb index 901ed70468..6aff027107 100644 --- a/railties/lib/generators/test_unit/model/model_generator.rb +++ b/railties/lib/generators/test_unit/model/model_generator.rb @@ -4,18 +4,16 @@ module TestUnit argument :attributes, :type => :hash, :default => {}, :banner => "field:type, field:type" check_class_collision :suffix => "Test" - - # TODO Add DEFAULTS support - class_option :skip_fixture, :type => :boolean, :default => false, - :desc => "Don't generate a fixture file" + conditional_class_option :fixture def create_test_file template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") end - # TODO Add fixture replacement support + invoke_for :fixture_replacement + def create_fixture_file - unless options[:skip_fixture] + if options[:fixture] && options[:fixture_replacement].nil? template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml") end end -- cgit v1.2.3