Sha256: 63f88632016733fe0182ef9093c5be80007424121986ac50418277db240d337a

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

require "spec_helper"

describe RedCloth do
  describe "#figure" do
    it "renders html" do
      html = RedCloth.convert("figure(The Rails logo). rails.png")
      html.should have_tag("p.figure") do |p|
        p.should have_tag("img[@src='../images/rails.png'][@alt='The Rails logo']")
        p.should have_tag("span.caption", "The Rails logo")
      end
    end
  end

  describe "#note" do
    it "renders html" do
      html = RedCloth.convert("note. Some important note!")
      html.should have_tag("p.note", "Some important note!")
    end
  end

  describe "#attention" do
    it "renders html" do
      html = RedCloth.convert("attention. Some warning note!")
      html.should have_tag("p.attention", "Some warning note!")
    end
  end

  describe "#file" do
    it "renders html" do
      Kitabu.stub :config => { :base_url => "http://example.com" }
      html = RedCloth.convert("file. app/models/users.rb")

      html.should have_tag("p.file") do |p|
        p.should have_tag("a[@href='http://example.com/app/models/users.rb']", "app/models/users.rb")
      end
    end
  end

  context "custom footnote helper" do
    it "renders html" do
      html = RedCloth.convert("Writing some text with a footnote %{this is a footnote}")
      html.should == %[<p>Writing some text with a footnote<span class="footnote">this is a footnote</span></p>]
    end

    it "ignores escaped notations" do
      html = RedCloth.convert("It must skip \\%{this}")
      html.should == %[<p>It must skip %{this}</p>]
    end
  end

  context "custom url helper" do
    it "renders html" do
      html = RedCloth.convert("<http://example.com>")
      html.should == %[<p><a href="http://example.com">http://example.com</a></p>]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kitabu-1.0.5 spec/kitabu/extensions/redcloth_spec.rb
kitabu-1.0.4 spec/kitabu/extensions/redcloth_spec.rb
kitabu-1.0.3 spec/kitabu/extensions/redcloth_spec.rb
kitabu-1.0.2 spec/kitabu/extensions/redcloth_spec.rb