diff options
Diffstat (limited to 'railties/test/generators/observer_generator_test.rb')
-rw-r--r-- | railties/test/generators/observer_generator_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb new file mode 100644 index 0000000000..65e18eb942 --- /dev/null +++ b/railties/test/generators/observer_generator_test.rb @@ -0,0 +1,33 @@ +require 'abstract_unit' +require 'generators/generators_test_helper' +require 'generators/rails/observer/observer_generator' + +class ObserverGeneratorTest < GeneratorsTestCase + + def test_invokes_default_orm + run_generator + assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/ + end + + def test_invokes_default_orm_with_class_path + 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", /class AccountObserverTest < ActiveSupport::TestCase/ + end + + def test_logs_if_the_test_framework_cannot_be_found + content = run_generator ["account", "--test-framework=rspec"] + assert_match /rspec \[not found\]/, content + end + + protected + + def run_generator(args=["account"]) + silence(:stdout) { Rails::Generators::ObserverGenerator.start args, :root => destination_root } + end + +end |