2009-06-25 05:24:35 -04:00
|
|
|
require 'generators/generators_test_helper'
|
2010-03-23 08:40:19 -04:00
|
|
|
require 'rails/generators/rails/observer/observer_generator'
|
2009-06-25 05:24:35 -04:00
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
class ObserverGeneratorTest < Rails::Generators::TestCase
|
|
|
|
include GeneratorsTestHelper
|
2010-01-03 10:34:32 -05:00
|
|
|
arguments %w(account)
|
2009-06-25 05:24:35 -04:00
|
|
|
|
2009-06-27 07:03:07 -04:00
|
|
|
def test_invokes_default_orm
|
2009-06-25 05:24:35 -04:00
|
|
|
run_generator
|
|
|
|
assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/
|
|
|
|
end
|
|
|
|
|
2009-06-27 07:03:07 -04:00
|
|
|
def test_invokes_default_orm_with_class_path
|
2009-06-25 05:24:35 -04:00
|
|
|
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
|
2009-06-27 07:03:07 -04:00
|
|
|
assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
|
2009-06-25 05:24:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_logs_if_the_test_framework_cannot_be_found
|
2009-07-08 06:55:50 -04:00
|
|
|
content = run_generator ["account", "--test-framework=rspec"]
|
|
|
|
assert_match /rspec \[not found\]/, content
|
2009-06-25 05:24:35 -04:00
|
|
|
end
|
|
|
|
end
|