Permalink
Browse files

Added tests for railtie_name and aliased it in engine as engine_name

  • Loading branch information...
1 parent bfccbc6 commit 2068b8cb6a8508fae9cd1a7f57e68d938c6403e6 @drogus drogus committed Jul 26, 2010
Showing with 18 additions and 0 deletions.
  1. +2 −0 railties/lib/rails/engine.rb
  2. +16 −0 railties/test/railties/railtie_test.rb
@@ -166,6 +166,7 @@ class Engine < Railtie
class << self
attr_accessor :called_from
+ alias :engine_name :railtie_name
def inherited(base)
unless base.abstract_railtie?
@@ -201,6 +202,7 @@ def endpoint(endpoint = nil)
end
delegate :middleware, :root, :paths, :to => :config
+ delegate :engine_name, :to => "self.class"
def load_tasks
super
@@ -19,6 +19,22 @@ def app
assert !Rails::Railtie.respond_to?(:config)
end
+ test "Railtie provides railtie_name" do
+ begin
+ class ::Foo < Rails::Railtie ; end
+ assert_equal "foo", ::Foo.railtie_name
+ ensure
+ Object.send(:remove_const, :"Foo")
+ end
+ end
+
+ test "railtie_name can be set manualy" do
+ class Foo < Rails::Railtie
+ railtie_name "bar"
+ end
+ assert_equal "bar", Foo.railtie_name
+ end
+
test "cannot inherit from a railtie" do
class Foo < Rails::Railtie ; end
assert_raise RuntimeError do

0 comments on commit 2068b8c

Please sign in to comment.