Permalink
Browse files

Clean up engine generators_test code and add test for models correctl…

…y namespaced
  • Loading branch information...
1 parent 32d35ba commit 77616702df35da2f095dfbaf229b0ae500eaa113 @radar radar committed with Stefan Sprenger Jun 6, 2011
Showing with 19 additions and 7 deletions.
  1. +19 −7 railties/test/engine/generators_test.rb
@@ -29,26 +29,38 @@ def tmp_path(*args)
def engine_path
tmp_path('foo_bar')
end
-
- def build_engine
- FileUtils.mkdir_p(engine_path)
- FileUtils.rm_r(engine_path)
+
+ def rails(cmd)
environment = File.expand_path('../../../../load_paths', __FILE__)
if File.exist?("#{environment}.rb")
require_environment = "-r #{environment}"
end
- `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/bin/rails plugin new #{engine_path} --full --mountable`
+ `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/bin/rails #{cmd}`
+ end
+
+ def build_engine
+ FileUtils.mkdir_p(engine_path)
+ FileUtils.rm_r(engine_path)
+
+ rails("plugin new #{engine_path} --full --mountable")
end
def setup
build_engine
end
- def test_omg
+ def test_controllers_are_correctly_namespaced
Dir.chdir(engine_path) do
- `rails g controller topics`
+ rails("g controller topics")
assert_file "app/controllers/foo_bar/topics_controller.rb"
end
end
+
+ def test_models_are_correctly_namespaced
+ Dir.chdir(engine_path) do
+ rails("g model topic")
+ assert_file "app/models/foo_bar/topic.rb"
+ end
+ end
end
end

0 comments on commit 7761670

Please sign in to comment.