Sha256: f090253b7e5d08e4e324d854926699989238366bec3c7a555439a6722bed4dfb

Contents?: true

Size: 1.6 KB

Versions: 10

Compression:

Stored size: 1.6 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

  it "should yield v when rendering" do
    mock_v = {}
    mock_v.should_receive(:in_the_block)
    @render.should_receive(:v).and_return(mock_v)
    @render.render(:haml_template) do |v|
      v.should be_a_kind_of(Hash)
      v.in_the_block
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pancake-0.1.25 spec/pancake/mixins/render_spec.rb
pancake-0.1.24 spec/pancake/mixins/render_spec.rb
pancake-0.1.22 spec/pancake/mixins/render_spec.rb
pancake-0.1.20 spec/pancake/mixins/render_spec.rb
pancake-0.1.19 spec/pancake/mixins/render_spec.rb
pancake-0.1.18 spec/pancake/mixins/render_spec.rb
pancake-0.1.17 spec/pancake/mixins/render_spec.rb
pancake-0.1.16 spec/pancake/mixins/render_spec.rb
pancake-0.1.15 spec/pancake/mixins/render_spec.rb
pancake-0.1.13 spec/pancake/mixins/render_spec.rb