Sha256: 1ae027f450ca78753086f11ee564b6e727425f3af8e15efe15f50d58a2e35b04

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"

describe SDoc::Helpers do
  before :each do
    @helpers = Class.new do
      include SDoc::Helpers
    end.new
  end

  describe "#strip_tags" do
    it "should strip out HTML tags from the given string" do
      strings = [
        [ %(<strong>Hello world</strong>),                                      "Hello world"          ],
        [ %(<a href="Streams.html">Streams</a> are great),                      "Streams are great"    ],
        [ %(<a href="https://github.com?x=1&y=2#123">zzak/sdoc</a> Standalone), "zzak/sdoc Standalone" ],
        [ %(<h1 id="module-AR::Cb-label-Foo+Bar">AR Cb</h1>),                   "AR Cb"                ],
        [ %(<a href="../Base.html">Base</a>),                                   "Base"                 ],
        [ %(Some<br>\ntext),                                                    "Some\ntext"           ]
      ]

      strings.each do |(html, stripped)|
        _(@helpers.strip_tags(html)).must_equal stripped
      end
    end
  end

  describe "#truncate" do
    it "should truncate the given text around a given length" do
      _(@helpers.truncate("Hello world", length: 5)).must_equal "Hello."
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/sdoc-2.6.1/spec/helpers_spec.rb
sdoc-2.6.1 spec/helpers_spec.rb
sdoc-2.6.0 spec/helpers_spec.rb
sdoc-2.5.0 spec/helpers_spec.rb
sdoc-2.4.0 spec/helpers_spec.rb
sdoc-2.3.2 spec/helpers_spec.rb
sdoc-2.3.1 spec/helpers_spec.rb
sdoc-2.3.0 spec/helpers_spec.rb
sdoc-2.2.0 spec/helpers_spec.rb