quickdraw/compilation_equivalence_cases/conditional_values.rb
Lines
0%0 of 56 covered
Branches
0%0 of 78 covered
Methods
0%0 of 6 covered
- Not run
- 3-68-913-1518-3739-525457-5962-6568-707375
- Never called
#<Class:EquivalenceCases::ConditionalValues::ConditionalValues>#equivalence_scenariosEquivalenceCases::ConditionalValues::ConditionalValues#initializeEquivalenceCases::ConditionalValues::ConditionalValues#view_templateEquivalenceCases::ConditionalValues::ConditionalValues#clear_nameEquivalenceCases::ConditionalValues::ConditionalValues#active?EquivalenceCases::ConditionalValues::ConditionalValues#dom_id
| 1 | # frozen_string_literal: true | |
| 2 | ||
| 3 | 0 | module EquivalenceCases |
| 4 | 0 | module ConditionalValues |
| 5 | 0 | class ConditionalValues < Phlex::HTML |
| 6 | 0 | def self.equivalence_scenarios |
| 7 | { | |
| 8 | 0 | "inactive" => -> (klass) { klass.new(active: false).call }, |
| 9 | 0 | "nil name" => -> (klass) { klass.new(name: nil).call }, |
| 10 | } | |
| 11 | end | |
| 12 | ||
| 13 | 0 | def initialize(active: true, name: "<name>") |
| 14 | 0 | @active = active |
| 15 | 0 | @name = name |
| 16 | end | |
| 17 | ||
| 18 | 0 | def view_template |
| 19 | 0 | div(class: @active ? "on" : "off") { "ternary" } |
| 20 | 0 | div(class: active? ? "on" : "off") { "method predicate" } |
| 21 | 0 | div(class: (@active ? "on" : nil), id: "static") |
| 22 | 0 | div(class: @active ? "on" : "off", id: dom_id) |
| 23 | 0 | div(class: @active && "on") |
| 24 | 0 | div(class: @name || "anonymous") |
| 25 | 0 | div(class: (@active ? "a" : "b") && (@name || "c")) |
| 26 | 0 | div(class: @active ? (@name ? "named" : "anonymous") : "off") |
| 27 | 0 | div(class: @active ? (active? ? "named" : "anonymous") : "off") |
| 28 | 0 | div(class: (plain("before"); @active) ? "on" : "off") |
| 29 | 0 | div(hidden: @active ? true : nil, tabindex: @active ? 0 : -1) |
| 30 | 0 | a(href: @active ? "javascript:alert(1)" : "/ok") { "guarded" } |
| 31 | 0 | div(class: if @active then "on" end) |
| 32 | 0 | div(class: unless @active then "off" end) |
| 33 | 0 | div(class: if @active then "on" elsif @name then "named" else "off" end) |
| 34 | 0 | div(class: ("on" if @active)) |
| 35 | 0 | div(class: ("off" unless @active), id: dom_id) |
| 36 | 0 | div(class: @active ? (@name ? "named" : "anonymous") : "off", id: clear_name) |
| 37 | 0 | div(class: (if @active then "on" elsif @name then "named" else "off" end), id: clear_name) |
| 38 | ||
| 39 | 0 | span { @active ? "on" : "off" } |
| 40 | 0 | span { active? ? "on" : "off" } |
| 41 | 0 | span { @active ? "<on>" : :"<off>" } |
| 42 | 0 | span { @active ? "on" : nil } |
| 43 | 0 | span { @active && "on" } |
| 44 | 0 | span { @name || "anonymous" } |
| 45 | 0 | span { (@active ? "a" : "b") } |
| 46 | 0 | span { @active ? (@name ? "named" : "anonymous") : "off" } |
| 47 | 0 | span { @active ? (active? ? "named" : "anonymous") : "off" } |
| 48 | 0 | span do |
| 49 | 0 | if @active |
| 50 | 0 | "on" |
| 51 | 0 | elsif @name |
| 52 | 0 | "named" |
| 53 | else | |
| 54 | 0 | "off" |
| 55 | end | |
| 56 | end | |
| 57 | 0 | span do |
| 58 | 0 | unless @active |
| 59 | 0 | "off" |
| 60 | end | |
| 61 | end | |
| 62 | 0 | span { (plain("before"); @active) ? "on" : "off" } |
| 63 | 0 | span { @active ? "on" : @name } |
| 64 | 0 | span { "on" if @active } |
| 65 | 0 | span { "off" unless @active } |
| 66 | end | |
| 67 | ||
| 68 | 0 | def clear_name |
| 69 | 0 | @name = nil |
| 70 | 0 | "cleared" |
| 71 | end | |
| 72 | ||
| 73 | 0 | def active? = @active |
| 74 | ||
| 75 | 0 | def dom_id = "generated" |
| 76 | end | |
| 77 | end | |
| 78 | end |