Sha256: 2a325e0dbba12d83913c3a8375d079913023ee4c8d558235fd4010f81dacd5ff

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Pancake::Mixins::Render do
  before do
    class ::RenderSpecClass
      include Pancake::Mixins::Render

      # setup the renderer
      roots << File.expand_path(File.join(File.dirname(__FILE__), "..", "fixtures", "render_templates"))
      push_paths :views, "/", "**/*"

      def params
        @params ||= {}
      end

      def string
        render :text => "A String"
      end

      def the_current_context
        "the current context"
      end
    end

    @render = RenderSpecClass.new
  end
  after do
    clear_constants "RenderSpecClass"
  end

  it "should allow me to render a string" do
    @render.string.should == "A String"
  end

  it "should render a haml" do
    @render.render(:haml_template).chomp.should == "IN HAML"
  end

  it "should render erb" do
    @render.render(:erb_template).should == "IN ERB"
  end

  it "should render an xml format" do
    @render.render(:haml_template, :format => :xml).chomp.should == "IN HAML XML"
  end

  it "should render an erb template for json" do
    @render.render(:erb_template, :format => :json).chomp.should == "IN ERB JSON"
  end

  it "should render with the rendering controller as the current context" do
    @render.render(:context_template)
    $captures.first.should be_a_kind_of(Pancake::Mixins::Render::ViewContext)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pancake-0.1.12 spec/pancake/mixins/render_spec.rb
pancake-0.1.10 spec/pancake/mixins/render_spec.rb
pancake-0.1.8 spec/pancake/mixins/render_spec.rb