Sha256: 87a2e213bea0ad38dcf891c7a69916b259476fdb0fdfdf7adcf7f227a3ebdd3d

Contents?: true

Size: 1.05 KB

Versions: 28

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

begin
  require 'tilt/erb'
rescue LoadError
  warn "tilt not installed, skipping render_each plugin test"  
else
describe "render_each plugin" do 
  it "calls render with each argument, returning joined string with all results" do
    app(:bare) do
      plugin :render_each
      def render_template(t, opts)
        "r#{t}#{opts[:locals][:foo] if opts[:locals]}#{opts[:bar]}#{opts[:locals][:bar] if opts[:locals]} "
      end 

      route do |r|
        r.root do
          render_each([1,2,3], :foo)
        end

        r.is 'a' do
          render_each([1,2,3], :bar, :local=>:foo, :bar=>4)
        end

        r.is 'b' do
          render_each([1,2,3], :bar, :local=>nil)
        end

        r.is 'c' do
          render_each([1,2,3], :bar, :locals=>{:foo=>4})
        end
      end
    end

    body.must_equal 'rfoo1 rfoo2 rfoo3 '
    body("/a").must_equal 'rbar14 rbar24 rbar34 '
    body("/b").must_equal 'rbar rbar rbar '
    body("/c").must_equal 'rbar41 rbar42 rbar43 '
  end
end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roda-2.29.0 spec/plugin/render_each_spec.rb
roda-2.28.0 spec/plugin/render_each_spec.rb
roda-2.27.0 spec/plugin/render_each_spec.rb
roda-2.26.0 spec/plugin/render_each_spec.rb
roda-2.25.0 spec/plugin/render_each_spec.rb
roda-2.24.0 spec/plugin/render_each_spec.rb
roda-2.23.0 spec/plugin/render_each_spec.rb
roda-2.22.0 spec/plugin/render_each_spec.rb
roda-2.21.0 spec/plugin/render_each_spec.rb
roda-2.20.0 spec/plugin/render_each_spec.rb
roda-2.19.0 spec/plugin/render_each_spec.rb
roda-2.18.0 spec/plugin/render_each_spec.rb
roda-2.17.0 spec/plugin/render_each_spec.rb
roda-2.16.0 spec/plugin/render_each_spec.rb
roda-2.15.0 spec/plugin/render_each_spec.rb
roda-2.14.0 spec/plugin/render_each_spec.rb
roda-2.13.0 spec/plugin/render_each_spec.rb
roda-2.12.0 spec/plugin/render_each_spec.rb
roda-2.11.0 spec/plugin/render_each_spec.rb
roda-2.10.0 spec/plugin/render_each_spec.rb