rails/railties/test/generators/observer_generator_test.rb
Akira Matsuda cce461511b be sure to parenthesize the arguments when the first one is a RegExp literal
this fixes: "warning: ambiguous first argument; put parentheses or even spaces"
because: you need this to tell the parser that you're not calling :/ method (division)
details (Japanese!): http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/42445?42370-43277
2011-05-18 23:20:19 +09:00

28 lines
931 B
Ruby

require 'generators/generators_test_helper'
require 'rails/generators/rails/observer/observer_generator'
class ObserverGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(account)
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
end