Sha256: f4745c62e923dc0315f22a6fe2994c8096b5dbb026694197f4897170083e8d40

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"

describe Machined::Processors::LayoutProcessor do
  it "wraps the content with a layout" do
    within_construct do |c|
      c.file "pages/index.html", "<h1>Hello World</h1>"
      c.file "views/layouts/main.html.haml", "#layout= yield"
      
      machined.pages["index.html"].to_s.should == "<div id='layout'><h1>Hello World</h1></div>\n"
    end
  end
  
  it "uses the default layout set in the configuration" do
    within_construct do |c|
      c.file "pages/index.html", "<h1>Hello World</h1>"
      c.file "views/layouts/application.html.haml", "#layout= yield"
      
      machined :layout => "application"
      machined.pages["index.html"].to_s.should == "<div id='layout'><h1>Hello World</h1></div>\n"
    end
  end
  
  it "does not wrap the content with a layout when layout is false" do
    within_construct do |c|
      c.file "pages/index.html", "<h1>Hello World</h1>"
      c.file "views/layouts/application.html.haml", "#layout= yield"
      
      machined :layout => false
      machined.pages["index.html"].to_s.should == "<h1>Hello World</h1>"
    end
  end
  
  it "adds the layout file as a dependency" do
    within_construct do |c|
      c.file "pages/index.html", "<h1>Hello World</h1>"
      dep = c.file "views/layouts/main.html.haml", "= yield"
      
      asset = machined.pages["index.html"]
      asset.should be_fresh
        
      dep.open("w") { |f| f.write("#layout= yield") }
      mtime = Time.now + 600
      dep.utime mtime, mtime
      
      asset.should be_stale
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
machined-0.4.0 spec/machined/processors/layout_processor_spec.rb
machined-0.3.1 spec/machined/processors/layout_processor_spec.rb
machined-0.3.0 spec/machined/processors/layout_processor_spec.rb
machined-0.2.2 spec/machined/processors/layout_processor_spec.rb
machined-0.2.1 spec/machined/processors/layout_processor_spec.rb
machined-0.2.0 spec/machined/processors/layout_processor_spec.rb