Sha256: 4d83700bc7ae310e856c31cd85fa5e98db0de6f803a069bdd1b45b62d7d08cc3

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require ::File.expand_path(
    ::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))

# ---------------------------------------------------------------------------
describe Webby::Helpers::CaptureHelper do
  CFN = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', 'capture_for_yaml.txt'))
  CLINES = [
    "--- ",
    "filter: ",
    "  - erb ",
    "--- ",
    "Hello world!",
    "<% content_for :sidebar do %>",
    "I'm sidebar content.",
    "<% end %>"
  ]

  before :all do
    ::File.open(CFN,'w') {|fd| fd.write CLINES.join("\n") }
  end

  before :each do
    @renderman = Webby::Renderer.new(
                 Webby::Resources::Page.new(CFN))
    @page_content = @renderman._render_page
  end

  after :all do
    ::FileUtils.rm_f(CFN)
  end

  it 'should always insert content into containing page' do
    @page_content.should_not be_nil
    @page_content.should eql("Hello world!\n\nI'm sidebar content.\n")
  end

  it "should return the stored content for the given key" do
    @renderman.content_for(:sidebar).should_not be_nil
    @renderman.content_for(:sidebar).should eql("\nI'm sidebar content.\n") # Note: Leading newline
  end

  it "should report if content is associated with a given key" do
    @renderman.content_for?(:sidebar).should == true
    @renderman.content_for?(:header).should == false
  end

  it "should clear content associated with a given key" do
    @renderman.content_for?(:sidebar).should == true
    @renderman.delete_content_for(:sidebar)
    @renderman.content_for?(:sidebar).should == false
  end

end

# EOF

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mikker-webby-0.9.4 spec/webby/helpers/capture_helper_spec.rb