From 4573fd2e06ee9b5a68f84f085f0a10c9ad6f129b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 25 Jun 2009 11:24:35 +0200 Subject: Added observer generator. --- .../test/generators/observer_generator_test.rb | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 railties/test/generators/observer_generator_test.rb (limited to 'railties/test') diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb new file mode 100644 index 0000000000..85c95c9dc7 --- /dev/null +++ b/railties/test/generators/observer_generator_test.rb @@ -0,0 +1,34 @@ +require 'abstract_unit' +require 'generators/generators_test_helper' +require 'generators/rails/observer/observer_generator' +require 'generators/test_unit/observer/observer_generator' + +class ObserverGeneratorTest < GeneratorsTestCase + + def test_observer_skeleton_is_created + run_generator + assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/ + end + + def test_observer_with_class_path_skeleton_is_created + run_generator ["admin/account"] + assert_file "app/models/admin/account_observer.rb", /class Admin::AccountObserver < ActiveRecord::Observer/ + end + + def test_invokes_default_test_framework + run_generator + assert_file "test/unit/account_observer_test.rb" + end + + def test_logs_if_the_test_framework_cannot_be_found + content = run_generator ["account", "--test-framework=unknown"] + assert_match /Could not find and invoke 'unknown:generators:observer'/, content + end + + protected + + def run_generator(args=["account"]) + silence(:stdout) { Rails::Generators::ObserverGenerator.start args, :root => destination_root } + end + +end -- cgit v1.2.3