Sha256: 6b815fa1ec863f959ad7be10314124736818412f3e031aa50db37f5885e8e85d

Contents?: true

Size: 957 Bytes

Versions: 14

Compression:

Stored size: 957 Bytes

Contents

require "inline_svg/transform_pipeline"

describe InlineSvg::TransformPipeline::Transformations::ClassAttribute do
  it "adds a style attribute to a SVG document" do
    document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
    transformation =
      InlineSvg::TransformPipeline::Transformations::StyleAttribute
        .create_with_value("padding: 10px")

    expect(transformation.transform(document).to_html).to eq(
      "<svg style=\"padding: 10px\">Some document</svg>\n"
    )
  end

  it "preserves existing style attributes on a SVG document" do
    xml = '<svg style="fill: red">Some document</svg>'
    document = Nokogiri::XML::Document.parse(xml)
    transformation =
      InlineSvg::TransformPipeline::Transformations::StyleAttribute
        .create_with_value("padding: 10px")

    expect(transformation.transform(document).to_html).to eq(
      "<svg style=\"fill: red;padding: 10px\">Some document</svg>\n"
    )
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
inline_svg-1.10.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.9.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.8.0 spec/transformation_pipeline/transformations/style_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/style_attribute_spec.rb
inline_svg-1.7.2 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.7.1 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.7.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.6.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.5.2 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.5.1 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.5.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.4.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.3.1 spec/transformation_pipeline/transformations/style_attribute_spec.rb
inline_svg-1.3.0 spec/transformation_pipeline/transformations/style_attribute_spec.rb