spec/presenter_spec.rb in curly-templates-2.3.2 vs spec/presenter_spec.rb in curly-templates-2.4.0
- old
+ new
@@ -3,10 +3,12 @@
module MonkeyComponents
def monkey
end
end
+ exposes_helper :foo
+
include MonkeyComponents
presents :midget, :clown, default: nil
presents :elephant, default: "Dumbo"
@@ -69,9 +71,32 @@
it "allows method calls on context-defined methods" do
context.should receive(:respond_to?).
with(:undefined, false).once.and_return(true)
subject.method(:undefined)
+ end
+ end
+
+ describe ".exposes_helper" do
+ let(:context) { double("context") }
+ subject {
+ CircusPresenter.new(context,
+ midget: "Meek Harolson",
+ clown: "Bubbles")
+ }
+
+ it "allows a method as a component" do
+ CircusPresenter.component_available?(:foo)
+ end
+
+ it "delegates the call to the context" do
+ context.should receive(:foo).once
+ subject.should_not receive(:method_missing)
+ subject.foo
+ end
+
+ it "doesn't delegate other calls to the context" do
+ expect { subject.bar }.to raise_error
end
end
describe ".presenter_for_path" do
it "returns the presenter class for the given path" do