2008-05-13 16:49:41 -04:00
|
|
|
require 'generators/generator_test_helper'
|
|
|
|
|
2008-10-13 22:43:58 -04:00
|
|
|
module Admin
|
|
|
|
end
|
|
|
|
|
2008-05-13 16:49:41 -04:00
|
|
|
class RailsControllerGeneratorTest < GeneratorTestCase
|
|
|
|
|
|
|
|
def test_controller_generates_controller
|
|
|
|
run_generator('controller', %w(products))
|
|
|
|
|
|
|
|
assert_generated_controller_for :products
|
|
|
|
assert_generated_functional_test_for :products
|
|
|
|
assert_generated_helper_for :products
|
2008-11-17 22:55:56 -05:00
|
|
|
assert_generated_helper_test_for :products
|
2008-05-13 16:49:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_controller_generates_namespaced_controller
|
|
|
|
run_generator('controller', %w(admin::products))
|
|
|
|
|
|
|
|
assert_generated_controller_for "admin::products"
|
|
|
|
assert_generated_functional_test_for "admin::products"
|
|
|
|
assert_generated_helper_for "admin::products"
|
2008-11-17 22:55:56 -05:00
|
|
|
assert_generated_helper_test_for "admin::products"
|
2008-05-13 16:49:41 -04:00
|
|
|
end
|
2008-07-11 13:09:25 -04:00
|
|
|
|
|
|
|
def test_controller_generates_namespaced_and_not_namespaced_controllers
|
2008-11-17 22:55:56 -05:00
|
|
|
run_generator('controller', %w(products))
|
|
|
|
|
|
|
|
# We have to require the generated helper to show the problem because
|
|
|
|
# the test helpers just check for generated files and contents but
|
|
|
|
# do not actually load them. But they have to be loaded (as in a real environment)
|
|
|
|
# to make the second generator run fail
|
|
|
|
require "#{RAILS_ROOT}/app/helpers/products_helper"
|
|
|
|
|
|
|
|
assert_nothing_raised do
|
|
|
|
begin
|
|
|
|
run_generator('controller', %w(admin::products))
|
|
|
|
ensure
|
|
|
|
# cleanup
|
|
|
|
Object.send(:remove_const, :ProductsHelper)
|
2008-07-11 13:09:25 -04:00
|
|
|
end
|
2008-11-17 22:55:56 -05:00
|
|
|
end
|
2008-07-11 13:09:25 -04:00
|
|
|
end
|
2008-05-13 16:49:41 -04:00
|
|
|
end
|