quickdraw/compilation_equivalence_cases/inline_svg.rb
Lines
100%23 of 23 covered
Branches
—0 of 0 covered
Methods
100%3 of 3 covered
| 1 | # frozen_string_literal: true | |
| 2 | ||
| 3 | 1 | module EquivalenceCases |
| 4 | 1 | module InlineSvg |
| 5 | 1 | class InlineSvg < Phlex::HTML |
| 6 | 1 | def self.equivalence_scenarios |
| 7 | { | |
| 8 | 4 | "fragment" => -> (klass) { klass.new.call(fragments: [:f]) }, |
| 9 | 2 | "bad class" => -> (klass) { klass.new(Object.new).call }, |
| 10 | } | |
| 11 | end | |
| 12 | ||
| 13 | 1 | def initialize(icon_class = "icon") |
| 14 | 10 | @icon_class = icon_class |
| 15 | 10 | @d = "M6 18L18 6" |
| 16 | end | |
| 17 | ||
| 18 | 1 | def view_template |
| 19 | 10 | svg(viewBox: "0 0 24 24", class: "icon") { |s| s.path(d: "M5 13l4 4L19 7") } |
| 20 | 5 | svg(class: @icon_class) do |s| |
| 21 | 4 | s.g(fill: "none") do |
| 22 | 4 | s.circle(cx: 12, cy: 12, r: 3) |
| 23 | 8 | s.text { "Label <b>" } |
| 24 | 8 | s.title { :a_symbol } |
| 25 | end | |
| 26 | 4 | s.clipPath(id: "c") |
| 27 | end | |
| 28 | 8 | svg { |s| s.path(d: @d) } |
| 29 | 8 | svg { |s| s.plain "text" } |
| 30 | 4 | svg |
| 31 | 4 | svg { |_s| } # rubocop:disable Lint/EmptyBlock |
| 32 | 12 | fragment(:f) { svg { |s| s.path(d: "in fragment") } } |
| 33 | rescue Phlex::ArgumentError | |
| 34 | 1 | plain "rescued" |
| 35 | end | |
| 36 | end | |
| 37 | end | |
| 38 | end |