File: class_attribute_spec.rb

package info (click to toggle)
ruby-inline-svg 1.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 480 kB
  • sloc: ruby: 1,711; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 913 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require "inline_svg/transform_pipeline"

describe InlineSvg::TransformPipeline::Transformations::ClassAttribute do
  it "adds a class attribute to a SVG document" do
    document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
    transformation = InlineSvg::TransformPipeline::Transformations::ClassAttribute.create_with_value("some-class")

    expect(transformation.transform(document).to_html).to eq(
      "<svg class=\"some-class\">Some document</svg>\n"
    )
  end

  it "preserves existing class attributes on a SVG document" do
    document = Nokogiri::XML::Document.parse('<svg class="existing things">Some document</svg>')
    transformation = InlineSvg::TransformPipeline::Transformations::ClassAttribute.create_with_value("some-class")

    expect(transformation.transform(document).to_html).to eq(
      "<svg class=\"existing things some-class\">Some document</svg>\n"
    )
  end
end