Sha256: 031b0b065b21ef41f678f6ce9e54864daec4bbaab8633a55985eeb82710dfe0f

Contents?: true

Size: 913 Bytes

Versions: 25

Compression:

Stored size: 913 Bytes

Contents

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
inline_svg-1.10.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.9.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.8.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/inline_svg-1.7.2/spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.7.2 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.7.1 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.7.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.6.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.5.2 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.5.1 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.5.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.4.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.3.1 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.3.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.2.3 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.2.2 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.2.1 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.2.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.1.0 spec/transformation_pipeline/transformations/class_attribute_spec.rb
inline_svg-1.0.1 spec/transformation_pipeline/transformations/class_attribute_spec.rb