quickdraw/compilation_equivalence_cases/interpolation_evaluation.rb
Lines
0%0 of 24 covered
Branches
0%0 of 2 covered
Methods
0%0 of 5 covered
- Not run
- 3-46-912-141620-2123-2428-3033-39
- Never called
EquivalenceCases::InterpolationEvaluation::Loud#initializeEquivalenceCases::InterpolationEvaluation::Loud#to_s#<Class:EquivalenceCases::InterpolationEvaluation::InterpolationEvaluation>#equivalence_scenariosEquivalenceCases::InterpolationEvaluation::InterpolationEvaluation#initializeEquivalenceCases::InterpolationEvaluation::InterpolationEvaluation#view_template
| 1 | # frozen_string_literal: true | |
| 2 | ||
| 3 | 0 | module EquivalenceCases |
| 4 | 0 | module InterpolationEvaluation |
| 5 | # Records when it's converted to a string, and can be made to raise. | |
| 6 | 0 | class Loud |
| 7 | 0 | def initialize(log, raise: false) |
| 8 | 0 | @log = log |
| 9 | 0 | @raise = raise |
| 10 | end | |
| 11 | ||
| 12 | 0 | def to_s |
| 13 | 0 | @log << "to_s" |
| 14 | 0 | raise "loud" if @raise |
| 15 | ||
| 16 | 0 | "loud" |
| 17 | end | |
| 18 | end | |
| 19 | ||
| 20 | 0 | class InterpolationEvaluation < Phlex::HTML |
| 21 | 0 | def self.equivalence_scenarios |
| 22 | { | |
| 23 | 0 | "fragment b" => -> (klass) { klass.new.call(fragments: [:b]) }, |
| 24 | 0 | "raising" => -> (klass) { klass.new(raising: true).call }, |
| 25 | } | |
| 26 | end | |
| 27 | ||
| 28 | 0 | def initialize(raising: false) |
| 29 | 0 | @log = [] |
| 30 | 0 | @loud = Loud.new(@log, raise: raising) |
| 31 | end | |
| 32 | ||
| 33 | 0 | def view_template |
| 34 | 0 | fragment(:a) { div { "a" } } |
| 35 | 0 | div { "#{@loud}" } |
| 36 | 0 | plain "p #{@loud}" |
| 37 | 0 | div(title: "t #{@loud}") |
| 38 | 0 | span { "#{@loud} #{@loud}" } |
| 39 | 0 | fragment(:b) { div { @log.join(",") } } |
| 40 | end | |
| 41 | end | |
| 42 | end | |
| 43 | end |