Sha256: db7aaab6c00a2ddb62ad01d5693e6d35b157f10ac8e5b0557adb8ef4929e2c84

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

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

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

      route do |r|
        r.on "home" do
          set_view_subdir 'views'
          view("home", :locals=>{:name => "Agent Smith", :title => "Home"}, :layout_opts=>{:locals=>{:title=>"Home"}})
        end

        r.on "about" do
          set_view_subdir 'views'
          render("views/about", :locals=>{:title => "About Roda"})
        end

        r.on "path" do
          render('views/about', :locals=>{:title => "Path"}, :layout_opts=>{:locals=>{:title=>"Home"}})
        end
      end
    end
  end

  it "should use set subdir if template name does not contain a slash" do
    body("/home").strip.should == "<title>Roda: Home</title>\n<h1>Home</h1>\n<p>Hello Agent Smith</p>"
  end

  it "should not use set subdir if template name contains a slash" do
    body("/about").strip.should == "<h1>About Roda</h1>"
  end

  it "should not change behavior when subdir is not set" do
    body("/path").strip.should == "<h1>Path</h1>"
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roda-2.0.0 spec/plugin/view_subdirs_spec.rb
roda-1.3.0 spec/plugin/view_subdirs_spec.rb