Sha256: a7c202624487d7550e1db360e27a33d6c2f2751bb134bdded04684cad8e14370

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "spec_helper"

describe Mango::ContentPage do
  describe "constants" do
    it "defines TEMPLATE_ENGINES" do
      expect(Mango::ContentPage::TEMPLATE_ENGINES).to eq({
        Tilt::BlueClothTemplate => :markdown,
        Tilt::HamlTemplate      => :haml,
        Tilt::ERBTemplate       => :erb,
        Tilt::LiquidTemplate    => :liquid
      })
    end

    it "defines DEFAULT_ATTRIBUTES" do
      expect(Mango::ContentPage::DEFAULT_ATTRIBUTES).to eq({
        "engine" => Mango::ContentPage::TEMPLATE_ENGINES.key(:markdown),
        "view"   => "page.haml"
      })
    end
  end

  #################################################################################################

  describe "attribute syntactic sugar" do
    before(:all) do
      data = <<-EOS
---
title: Syntactic Sugar Makes Life Sweeter
view: template.haml
---
EOS
      @page = Mango::ContentPage.new(data: data)
    end

    it "sweetens the title attribute" do
      expect(@page.title).to eq(@page.attributes["title"])
    end

    it "sweetens the view attribute" do
      expect(@page.view).to eq("template.haml")
    end

    it "doesn't sweeten an unknown attribute" do
      expect { @page.unknown }.to raise_exception(NoMethodError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mango-0.9.0 spec/lib/content_page_spec.rb