Sha256: 53572b4cd2b3be7cc23ef1cac1d6883b988f926564d436bb0e7899429572e532

Contents?: true

Size: 1.38 KB

Versions: 22

Compression:

Stored size: 1.38 KB

Contents

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

begin
  require 'tilt/erb'
rescue LoadError
  warn "tilt not installed, skipping multi_view plugin test"  
else
describe "multi_view plugin" do 
  before do
    app(:bare) do
      plugin :render, :views=>'spec/views', :layout=>'layout-yield'
      plugin :multi_view

      route do |r|
        r.multi_view(['a', 'b', 'c'])
      end
    end
  end

  it "supports easy rendering of multiple views by name" do
    body('/a').gsub(/\s+/, '').must_equal "HeaderaFooter"
    body('/b').gsub(/\s+/, '').must_equal "HeaderbFooter"
    body('/c').gsub(/\s+/, '').must_equal "HeadercFooter"
    status('/d').must_equal 404
    status('/a', 'REQUEST_METHOD'=>'POST').must_equal 404
  end
end

describe "multi_view plugin multi_view_compile method " do 
  before do
    app(:bare) do
      plugin :render, :views=>'spec/views', :layout=>'layout-yield'
      plugin :multi_view
      regexp = multi_view_compile(['a', 'b', 'c'])

      route do |r|
        r.multi_view(regexp)
      end
    end
  end

  it "supports easy rendering of multiple views by name" do
    body('/a').gsub(/\s+/, '').must_equal "HeaderaFooter"
    body('/b').gsub(/\s+/, '').must_equal "HeaderbFooter"
    body('/c').gsub(/\s+/, '').must_equal "HeadercFooter"
    status('/d').must_equal 404
    status('/a', 'REQUEST_METHOD'=>'POST').must_equal 404
  end
end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
roda-2.9.0 spec/plugin/multi_view_spec.rb
roda-2.8.0 spec/plugin/multi_view_spec.rb