spec/controller/helpers_spec.rb in stealth-1.0.0.pre1 vs spec/controller/helpers_spec.rb in stealth-1.0.0.pre2

- old
+ new

@@ -14,10 +14,14 @@ helper :all def say_hello_world hello_world end + + def say_kaboom + hello_world2 + end end class PdfController < Stealth::Controller def say_pdf_name generate_pdf_name @@ -31,10 +35,16 @@ class AllHelpersController < Stealth::Controller helper :all end + class InheritedHelpersController < AllHelpersController + def say_hello_world + hello_world + end + end + class SizzleController < Stealth::Controller helper :standalone def say_sizzle @@ -76,13 +86,29 @@ it "should load all helpers if :all is used" do expect(AllHelpersController._helpers.instance_methods).to match_array(all_helper_methods) end + it "should load all helpers if parent class inherits all helpers" do + expect(InheritedHelpersController._helpers.instance_methods).to match_array(all_helper_methods) + end + + it "should allow a controller that has inherited all helpers to access a helper method" do + expect { + InheritedHelpersController.new(service_message: facebook_message.message_with_text).say_hello_world + }.to_not raise_error + end + it "should allow a controller that has loaded all helpers to access a helper method" do expect { Fun::GamesController.new(service_message: facebook_message.message_with_text).say_hello_world }.to_not raise_error + end + + it "should raise an error if a helper method does not exist" do + expect { + Fun::GamesController.new(service_message: facebook_message.message_with_text).say_kaboom + }.to raise_error(NameError) end it "should allow a controller action to access a helper method" do expect { Fun::PdfController.new(service_message: facebook_message.message_with_text).say_pdf_name