Sha256: ad54b5ac68e08d1f36fb55cc7127102cd812644aebccb35df1721e83e9fcde9f
Contents?: true
Size: 1.46 KB
Versions: 5
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe Rafters::ComponentRenderer do let(:view_context) { double("ViewContext").as_null_object } let(:controller) { double("Controller").as_null_object } before do view_context.stub(:render).and_return("<p>Output</p>") view_context.stub(:content_tag).and_yield controller.stub(:view_context).and_return(view_context) end describe "when initialized" do before do Rafters.stub(:view_paths).and_return(["/path/to/views"]) end it "should add the view paths for all components to the controller" do controller.should_receive(:prepend_view_path).with("/path/to/views") Rafters::ComponentRenderer.new(controller) end end describe "#render" do subject { Rafters::ComponentRenderer.new(controller) } let(:component) { double("Component").as_null_object } before do component.stub(:attributes).and_return({ title: "Foo" }) component.stub(:template_name).and_return("template") end it "renders the component template with it's settings and attributes" do view_context.should_receive(:render).with(file: "/template", locals: { title: "Foo" }) subject.render(component) end context "with a specified template name" do it "renders the component with the specified template" do view_context.should_receive(:render).with(file: "/custom_template", locals: { title: "Foo" }) subject.render(component, "custom_template") end end end end
Version data entries
5 entries across 5 versions & 1 rubygems