Sha256: eb8ef07a10b4035dc50d5892b63f7488ef24d37cdbab09d6ba8e4b295fe62648

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 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 not "leak" any content to the containing page' do
    @page_content.should_not be_nil
    @page_content.should eql("Hello world!\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

3 entries across 3 versions & 2 rubygems

Version Path
TwP-webby-0.9.4.1 spec/webby/helpers/capture_helper_spec.rb
webby-0.9.4 spec/webby/helpers/capture_helper_spec.rb
webby-0.9.4-x86-mswin32 spec/webby/helpers/capture_helper_spec.rb