Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enough Coverage To Beat The Band

Enough Coverage To Beat The Band

The lights cut out. The crowd roars. It’s time. The band takes the stage. They’ve practiced the songs, particularly the covers. They’ve sound checked the coverage of the speakers. They know the lighting rig has the proper colored gels covering the lamps. They’re nervous, but they’ve got it all covered.

Similarly, code coverage can give you confidence before your app performs on production and also tell you how live code is used (or not used). We’ll cover how to leverage ruby’s different coverage measurement techniques in concert to assist your crew and delight your audience.

Kevin Murphy

October 25, 2020
Tweet

More Decks by Kevin Murphy

Other Decks in Programming

Transcript

  1. Kevin Murphy
    Enough Coverage
    To Bea
    t The Band

    View full-size slide

  2. Kevin Murphy
    Enough Coverage
    To Bea
    t The Band

    View full-size slide

  3. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  4. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  5. kevinjmurphy.com
    concert = Concert.new(“Blue Ridge Ruby")

    View full-size slide

  6. Test Coverage

    View full-size slide

  7. kevinjmurphy.com
    setlist.add_song(TheLineBeginsToBlur.new)


    View full-size slide

  8. kevinjmurphy.com
    setlist.add_song(TheLineBeginsToBlur.new)


    setlist.add_song(OneShotWayToGetThere.new)


    View full-size slide

  9. kevinjmurphy.com
    setlist.add_song(TheLineBeginsToBlur.new)


    setlist.add_song(OneShotWayToGetThere.new)


    setlist.add_song(VariousMethodsOfEscape.new)


    View full-size slide

  10. kevinjmurphy.com
    setlist.add_song(TheLineBeginsToBlur.new)


    setlist.add_song(OneShotWayToGetThere.new)


    setlist.add_song(VariousMethodsOfEscape.new)


    setlist.add_song(BranchesBones.new)


    View full-size slide

  11. kevinjmurphy.com
    setlist.add_song(TheLineBeginsToBlur.new)


    setlist.add_song(OneShotWayToGetThere.new)


    setlist.add_song(VariousMethodsOfEscape.new)


    setlist.add_song(BranchesBones.new)


    concert.setlist = setlist

    View full-size slide

  12. kevinjmurphy.com
    concert.perform

    View full-size slide

  13. kevinjmurphy.com
    setlist.songs
    [


    TheLineBeginsToBlur.new,


    OneShotWayToGetThere.new,


    VariousMethodsOfEscape.new,


    BranchesBones.new,


    ]

    View full-size slide

  14. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  15. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def pluck(fret:)


    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  16. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def pluck(fret:)


    if exhausted?


    break_string


    end


    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  17. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def pluck(fret:)


    if exhausted?


    break_string


    else


    @tension -= 1


    play_note(fret)


    end


    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  18. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def exhausted?


    @tension.negative?


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  19. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def exhausted?


    @tension.negative? || rand(1..1000) == 3


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  20. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def break_string






    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  21. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def break_string


    @broken = true




    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  22. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def break_string


    @broken = true


    BrokenStringSound.new


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  23. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    # lib/tour_leg_1.rb


    10.times do


    end

    View full-size slide

  24. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    # lib/tour_leg_1.rb


    10.times do


    concert.perform


    end

    View full-size slide

  25. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    require "coverage"


    View full-size slide

  26. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    require "coverage"


    Coverage.start(lines: true)


    View full-size slide

  27. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    require "coverage"


    Coverage.start(lines: true)


    load "lib/tour_leg_1.rb"


    View full-size slide

  28. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    require "coverage"


    Coverage.start(lines: true)


    load "lib/tour_leg_1.rb"


    result = Coverage.result

    View full-size slide

  29. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "lib/tour_leg_1.rb"=> {:lines => […]},





    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},





    }

    View full-size slide

  30. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},


    }

    View full-size slide

  31. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},


    }
    File

    View full-size slide

  32. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},


    }
    File
    Mode

    View full-size slide

  33. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},


    }
    File
    Mode
    Line 1 Count

    View full-size slide

  34. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    {


    "…guitar/string.rb" => {:lines => [1, 1, 1, 1, 1, 1, nil,…]},


    }
    File
    Mode
    Line 1 Count
    Irrelevant Line 7

    View full-size slide

  35. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    attr_reader :tension


    attr_reader :tuning_note


    def initialize(number:, tuning_note:)


    end
    4


    5


    6


    7


    8
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  36. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    string_lines = result["…guitar/string.rb"][:lines]


    View full-size slide

  37. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def break_string


    @broken = true


    BrokenStringSound.new


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0
    53


    54


    55


    56

    View full-size slide

  38. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    class String


    def break_string


    @broken = true


    BrokenStringSound.new


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0
    53


    54


    55


    56

    View full-size slide

  39. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    string_lines = result["…guitar/string.rb"][:lines]


    View full-size slide

  40. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    string_lines = result["…guitar/string.rb"][:lines]


    "Number of broken strings: #{string_lines[53]}"


    View full-size slide

  41. kevinjmurphy.com
    The Li
    ne Begi
    ns To Blur
    string_lines = result["…guitar/string.rb"][:lines]


    "Number of broken strings: #{string_lines[53]}"


    => Number of broken strings: 16

    View full-size slide

  42. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  43. kevinjmurphy.com
    setlist.songs
    [


    TheLineBeginsToBlur.new,


    OneShotWayToGetThere.new,


    VariousMethodsOfEscape.new,


    BranchesBones.new,


    ]

    View full-size slide

  44. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  45. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  46. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  47. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  48. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  49. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    Nine Inch Nails


    CC BY-NC-SA 2.0
    drummer

    View full-size slide

  50. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class Patch


    attr_reader :sound


    attr_reader :effect


    attr_reader :filter


    attr_reader :oscillator


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  51. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class Synthesizer


    def program(note)






    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  52. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class Synthesizer


    def program(note)


    set_patch(note.synth_sound.patch)








    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  53. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class Synthesizer


    def program(note)


    set_patch(note.synth_sound.patch)


    play_key(


    key: note.synth_sound.key,


    duration: note.duration,


    )


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  54. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class MoogPatchMemory


    def read(location)


    case location





    end


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  55. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    class MoogPatchMemory


    def read(location)


    case location





    end


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  56. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location






    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  57. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]








    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  58. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]


    when :a2


    @memory[1]






    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  59. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]


    when :a2


    @memory[1]


    when :b1


    @memory[2]






    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  60. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]


    when :a2


    @memory[1]


    when :b1


    @memory[2]


    when :b2


    @memory[3]


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  61. kevinjmurphy.com
    # lib/festival_setlist.rb


    moog = Synthesizer.new(brand: :moog)


    One(Shot) Wa
    y To Get There

    View full-size slide

  62. kevinjmurphy.com
    # lib/festival_setlist.rb


    moog = Synthesizer.new(brand: :moog)


    moog.save_patch(location: :a1, patch: beep)


    One(Shot) Wa
    y To Get There

    View full-size slide

  63. kevinjmurphy.com
    # lib/festival_setlist.rb


    moog = Synthesizer.new(brand: :moog)


    moog.save_patch(location: :a1, patch: beep)


    moog.save_patch(location: :a2, patch: boop)


    One(Shot) Wa
    y To Get There

    View full-size slide

  64. kevinjmurphy.com
    # lib/festival_setlist.rb


    moog = Synthesizer.new(brand: :moog)


    moog.save_patch(location: :a1, patch: beep)


    moog.save_patch(location: :a2, patch: boop)


    moog.save_patch(location: :b1, patch: moog_buzz)


    One(Shot) Wa
    y To Get There

    View full-size slide

  65. kevinjmurphy.com
    # lib/festival_setlist.rb


    moog = Synthesizer.new(brand: :moog)


    moog.save_patch(location: :a1, patch: beep)


    moog.save_patch(location: :a2, patch: boop)


    moog.save_patch(location: :b1, patch: moog_buzz)


    moog.save_patch(location: :b2, patch: whirr)
    One(Shot) Wa
    y To Get There

    View full-size slide

  66. kevinjmurphy.com
    # lib/festival_setlist.rb


    concert.perform
    One(Shot) Wa
    y To Get There

    View full-size slide

  67. kevinjmurphy.com
    require "coverage"


    One(Shot) Wa
    y To Get There

    View full-size slide

  68. kevinjmurphy.com
    require "coverage"


    Coverage.start(oneshot_lines: true)


    One(Shot) Wa
    y To Get There

    View full-size slide

  69. kevinjmurphy.com
    require "coverage"


    Coverage.start(oneshot_lines: true)


    load "lib/festival_setlist.rb"


    One(Shot) Wa
    y To Get There

    View full-size slide

  70. kevinjmurphy.com
    require "coverage"


    Coverage.start(oneshot_lines: true)


    load "lib/festival_setlist.rb"


    result = Coverage.result
    One(Shot) Wa
    y To Get There

    View full-size slide

  71. kevinjmurphy.com
    {


    "lib/festival_setlist.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    "moog_patch_memory.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    }
    One(Shot) Wa
    y To Get There

    View full-size slide

  72. kevinjmurphy.com
    {


    "moog_patch_memory.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    }
    One(Shot) Wa
    y To Get There

    View full-size slide

  73. kevinjmurphy.com
    {


    "moog_patch_memory.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    }
    File
    One(Shot) Wa
    y To Get There

    View full-size slide

  74. kevinjmurphy.com
    {


    "moog_patch_memory.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    }
    File
    Mode
    One(Shot) Wa
    y To Get There

    View full-size slide

  75. kevinjmurphy.com
    {


    "moog_patch_memory.rb"=>{:oneshot_lines=>[1, 2, 3…]},


    }
    File
    Mode
    executed line numbers
    One(Shot) Wa
    y To Get There

    View full-size slide

  76. kevinjmurphy.com
    moog = result["moog_patch_memory.rb"][:oneshot_lines]


    One(Shot) Wa
    y To Get There

    View full-size slide

  77. kevinjmurphy.com
    moog = result["moog_patch_memory.rb"][:oneshot_lines]


    => [1, 2, 3, 4, 5, 7, 11, 15, 28, 41, 43, 8, 29, 31, 33, 35, 37, 12, 44, 46, 16,
    18, 20, 24]
    One(Shot) Wa
    y To Get There

    View full-size slide

  78. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]


    when :a2


    @memory[1]


    when :b1


    @memory[2]


    when :b2


    @memory[3]


    Nine Inch Nails CC BY-NC-SA 2.0
    16


    17


    18


    19


    20


    21


    22


    23


    24

    View full-size slide

  79. kevinjmurphy.com
    One(Shot) Wa
    y To Get There
    case location


    when :a1


    @memory[0]


    when :a2


    @memory[1]


    when :b1


    @memory[2]


    when :b2


    @memory[3]


    Nine Inch Nails CC BY-NC-SA 2.0
    16


    17


    18


    19


    20


    21


    22


    23


    24

    View full-size slide

  80. kevinjmurphy.com
    puts "Moog Keyboard"


    puts "=============="


    One(Shot) Wa
    y To Get There

    View full-size slide

  81. kevinjmurphy.com
    puts "Moog Keyboard"


    puts "=============="


    puts "Location A1: #{moog.include?(18) ? 'Y' : 'N'}"


    One(Shot) Wa
    y To Get There

    View full-size slide

  82. kevinjmurphy.com
    puts "Moog Keyboard"


    puts "=============="


    puts "Location A1: #{moog.include?(18) ? 'Y' : 'N'}"


    puts "Location A2: #{moog.include?(20) ? 'Y' : 'N'}"


    One(Shot) Wa
    y To Get There

    View full-size slide

  83. kevinjmurphy.com
    puts "Moog Keyboard"


    puts "=============="


    puts "Location A1: #{moog.include?(18) ? 'Y' : 'N'}"


    puts "Location A2: #{moog.include?(20) ? 'Y' : 'N'}"


    puts "Location B1: #{moog.include?(22) ? 'Y' : 'N'}"


    One(Shot) Wa
    y To Get There

    View full-size slide

  84. kevinjmurphy.com
    puts "Moog Keyboard"


    puts "=============="


    puts "Location A1: #{moog.include?(18) ? 'Y' : 'N'}"


    puts "Location A2: #{moog.include?(20) ? 'Y' : 'N'}"


    puts "Location B1: #{moog.include?(22) ? 'Y' : 'N'}"


    puts "Location B2: #{moog.include?(24) ? 'Y' : 'N'}"
    One(Shot) Wa
    y To Get There

    View full-size slide

  85. kevinjmurphy.com
    Moog Keyboard


    =============


    Location A1: Y


    Location A2: Y


    Location B1: N


    Location B2: Y
    One(Shot) Wa
    y To Get There

    View full-size slide

  86. kevinjmurphy.com
    Moog Keyboard


    =============


    Location A1: Y


    Location A2: Y


    Location B1: N


    Location B2: Y
    One(Shot) Wa
    y To Get There
    Nord Keyboard


    =============


    Location A1: Y


    Location A2: N


    Location B1: N


    Location B2: N

    View full-size slide

  87. kevinjmurphy.com
    Moog Keyboard


    =============


    Location A1: Y


    Location A2: Y


    Location B1: Y


    Location B2: Y
    One(Shot) Wa
    y To Get There
    Nord Keyboard


    =============


    Location A1: Y


    Location A2: N


    Location B1: N


    Location B2: N

    View full-size slide

  88. kevinjmurphy.com
    Moog Keyboard


    =============


    Location A1: Y


    Location A2: Y


    Location B1: Y


    Location B2: Y
    One(Shot) Wa
    y To Get There
    Nord Keyboard


    =============


    Location A1: Y


    Location A2: N


    Location B1: N


    Location B2: N

    View full-size slide

  89. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  90. kevinjmurphy.com
    setlist.songs
    [


    TheLineBeginsToBlur.new,


    OneShotWayToGetThere.new,


    VariousMethodsOfEscape.new,


    BranchesBones.new,


    ]

    View full-size slide

  91. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  92. kevinjmurphy.com

    View full-size slide

  93. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  94. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  95. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  96. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  97. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def trigger(note)




    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  98. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def trigger(note)


    composition = note.lighting






    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  99. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def trigger(note)


    composition = note.lighting


    @powered_lights[composition.light].trigger(


    color: composition.color,


    effect: composition.effect,


    )


    end


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  100. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class BeamProjector


    def trigger(color:, effect:)


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  101. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class CanLight


    def trigger(color:, effect:)


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  102. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class MovingLight


    def trigger(color:, effect:)


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  103. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class Spotlight


    def trigger(color:, effect:)


    end


    end
    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  104. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    # lib/lighting_inspection.rb


    controller = LightingController.new


    setlist.lighting = controller


    View full-size slide

  105. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    # lib/lighting_inspection.rb


    controller = LightingController.new


    setlist.lighting = controller


    concert.set_up


    View full-size slide

  106. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    # lib/lighting_inspection.rb


    controller = LightingController.new


    setlist.lighting = controller


    concert.set_up


    concert.perform


    View full-size slide

  107. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    # lib/lighting_inspection.rb


    controller = LightingController.new


    setlist.lighting = controller


    concert.set_up


    concert.perform


    concert.load_out

    View full-size slide

  108. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    require "coverage"


    View full-size slide

  109. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    require "coverage"


    Coverage.start(methods: true)


    View full-size slide

  110. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    require "coverage"


    Coverage.start(methods: true)


    load "lib/lighting_inspection.rb"


    View full-size slide

  111. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    require "coverage"


    Coverage.start(methods: true)


    load "lib/lighting_inspection.rb"


    result = Coverage.result


    View full-size slide

  112. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    "spotlight.rb"=>


    {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    "beam_projector.rb"=>


    {:methods=>{[BeamProjector, :trigger, 4, 6, 6, 9]=>0}},


    "can_light.rb"=>


    {:methods=>{[CanLight, :trigger, 4, 6, 6, 9]=>2}},


    "moving_light.rb"=>


    {:methods=>{[MovingLight, :trigger, 4, 6, 6, 9]=>6}},


    View full-size slide

  113. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    V
    ari
    ous Methods Of Escape

    View full-size slide

  114. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    File
    V
    ari
    ous Methods Of Escape

    View full-size slide

  115. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    File
    Mode
    V
    ari
    ous Methods Of Escape

    View full-size slide

  116. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    File
    Mode
    V
    ari
    ous Methods Of Escape
    method

    View full-size slide

  117. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    File
    Mode
    V
    ari
    ous Methods Of Escape
    method
    count

    View full-size slide

  118. kevinjmurphy.com
    {


    "spotlight.rb"=> {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    }
    File
    Mode
    V
    ari
    ous Methods Of Escape
    method
    count

    View full-size slide

  119. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape

    View full-size slide

  120. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    count

    View full-size slide

  121. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    class count

    View full-size slide

  122. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    method
    class count

    View full-size slide

  123. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    method
    class start line count

    View full-size slide

  124. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    method
    class start line
    start column
    count

    View full-size slide

  125. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    method
    class start line
    start column
    end line
    count

    View full-size slide

  126. kevinjmurphy.com
    [Spotlight, :trigger, 4, 6, 6, 9] => 2


    V
    ari
    ous Methods Of Escape
    method
    class start line
    start column
    end line
    end column
    count

    View full-size slide

  127. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    "spotlight.rb"=>


    {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    "beam_projector.rb"=>


    {:methods=>{[BeamProjector, :trigger, 4, 6, 6, 9]=>0}},


    "can_light.rb"=>


    {:methods=>{[CanLight, :trigger, 4, 6, 6, 9]=>2}},


    "moving_light.rb"=>


    {:methods=>{[MovingLight, :trigger, 4, 6, 6, 9]=>6}},


    View full-size slide

  128. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    "spotlight.rb"=>


    {:methods=>{[Spotlight, :trigger, 4, 6, 6, 9]=>2}},


    "beam_projector.rb"=>


    {:methods=>{[BeamProjector, :trigger, 4, 6, 6, 9]=>0}},


    "can_light.rb"=>


    {:methods=>{[CanLight, :trigger, 4, 6, 6, 9]=>2}},


    "moving_light.rb"=>


    {:methods=>{[MovingLight, :trigger, 4, 6, 6, 9]=>6}},


    View full-size slide

  129. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def turn_on_lights


    @powered_lights[:beam_projector] = BeamProjector.new


    @powered_lights[:can] = CanLight.new


    @powered_lights[:moving_light] = MovingLight.new


    @powered_lights[:spotlight] = Spotlight.new


    end


    end


    View full-size slide

  130. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def turn_on_lights


    @powered_lights[:beam_projector] = BeamProjector.new


    @powered_lights[:can] = CanLight.new


    @powered_lights[:moving_light] = MovingLight.new


    @powered_lights[:spotlight] = Spotlight.new


    end


    end


    View full-size slide

  131. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def turn_on_lights


    @powered_lights[:beam_projector] = BeamProjector.new


    @powered_lights[:can] = CanLight.new


    @powered_lights[:moving_light] = MovingLight.new


    @powered_lights[:spotlight] = Spotlight.new


    end


    end


    View full-size slide

  132. kevinjmurphy.com
    V
    ari
    ous Methods Of Escape
    class LightingController


    def turn_on_lights


    @powered_lights[:can] = CanLight.new


    @powered_lights[:moving_light] = MovingLight.new


    @powered_lights[:spotlight] = Spotlight.new


    end


    end


    View full-size slide

  133. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  134. kevinjmurphy.com
    setlist.songs
    [


    TheLineBeginsToBlur.new,


    OneShotWayToGetThere.new,


    VariousMethodsOfEscape.new,


    BranchesBones.new,


    ]

    View full-size slide

  135. Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  136. kevinjmurphy.com
    Nine Inch Nails


    CC BY-NC-SA 2.0
    Nine Inch Nails


    CC BY-NC-SA 2.0
    Nine Inch Nails


    CC BY-NC-SA 2.0
    Nine Inch Nails


    CC BY-NC-SA 2.0
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  137. kevinjmurphy.com
    Branches
    /Bones
    # lib/rehearsal.rb


    song = BranchesBones.new


    View full-size slide

  138. kevinjmurphy.com
    Branches
    /Bones
    # lib/rehearsal.rb


    song = BranchesBones.new


    song.performers = band


    View full-size slide

  139. kevinjmurphy.com
    Branches
    /Bones
    # lib/rehearsal.rb


    song = BranchesBones.new


    song.performers = band


    song.play


    View full-size slide

  140. kevinjmurphy.com
    Branches
    /Bones
    require "coverage"


    View full-size slide

  141. kevinjmurphy.com
    Branches
    /Bones
    require "coverage"


    Coverage.start(:all)


    View full-size slide

  142. kevinjmurphy.com
    Branches
    /Bones
    require "coverage"


    Coverage.start(:all)


    load "lib/rehearsal.rb"


    View full-size slide

  143. kevinjmurphy.com
    Branches
    /Bones
    require "coverage"


    Coverage.start(:all)


    load "lib/rehearsal.rb"


    result = Coverage.result

    View full-size slide

  144. kevinjmurphy.com
    Branches
    /Bones
    "branches_bones.rb"=>{


    :lines=>[1, 1, 1, 1, 1, nil, nil, nil, nil, nil, 1, nil, 1, nil, 1, nil, nil, nil, 1, nil, 1, nil, nil, nil, 1, nil,
    1, nil, nil, nil, nil, nil, 1, 2, nil, nil, 2, nil, nil, nil, nil, 2, nil, 2, 8, nil, nil, nil, nil, nil],


    :branches=>{[:if, 0, 34, 25, 34, 67]=>{[:then, 1, 34, 60, 34, 62]=>0, [:else, 2, 34, 65, 34,
    67]=>2}, [:if, 3, 42, 18, 42, 99]=>{[:then, 4, 42, 41, 42, 75]=>0, [:else, 5, 42, 78, 42, 99]=>2}},


    :methods=>{


    [RubyCoverBand::Songs::BranchesBones, :chorus, 33, 6, 47, 9]=>2


    [RubyCoverBand::Songs::BranchesBones, :outro, 25, 6, 29, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :verse_2, 19, 6, 23, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :verse_1, 13, 6, 17, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :initialize, 4, 6, 9, 9]=>1}},

    View full-size slide

  145. kevinjmurphy.com
    Branches
    /Bones
    "branches_bones.rb"=>{


    :lines=>[1, 1, 1, 1, 1, nil, nil, nil, nil, nil, 1, nil, 1, nil, 1, nil, nil, nil, 1, nil, 1, nil, nil, nil, 1, nil,
    1, nil, nil, nil, nil, nil, 1, 2, nil, nil, 2, nil, nil, nil, nil, 2, nil, 2, 8, nil, nil, nil, nil, nil],


    :branches=>{[:if, 0, 34, 25, 34, 67]=>{[:then, 1, 34, 60, 34, 62]=>0, [:else, 2, 34, 65, 34,
    67]=>2}, [:if, 3, 42, 18, 42, 99]=>{[:then, 4, 42, 41, 42, 75]=>0, [:else, 5, 42, 78, 42, 99]=>2}},


    :methods=>{


    [RubyCoverBand::Songs::BranchesBones, :chorus, 33, 6, 47, 9]=>2


    [RubyCoverBand::Songs::BranchesBones, :outro, 25, 6, 29, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :verse_2, 19, 6, 23, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :verse_1, 13, 6, 17, 9]=>1,


    [RubyCoverBand::Songs::BranchesBones, :initialize, 4, 6, 9, 9]=>1}},

    View full-size slide

  146. kevinjmurphy.com
    Branches
    /Bones
    song_coverage = result["branches_bones.rb"]


    song_coverage.keys


    View full-size slide

  147. kevinjmurphy.com
    Branches
    /Bones
    song_coverage = result["branches_bones.rb"]


    song_coverage.keys


    => [:lines, :methods, :branches]

    View full-size slide

  148. kevinjmurphy.com
    Branches
    /Bones
    song_coverage[:lines].include?(0)


    => false

    View full-size slide

  149. kevinjmurphy.com
    Branches
    /Bones
    song_coverage[:methods].values.include?(0)


    => false

    View full-size slide

  150. kevinjmurphy.com
    Branches
    /Bones
    song_coverage[:branches]


    => {[:if, 0, 34, 25, 34, 67]=>{


    [:then, 1, 34, 60, 34, 62]=>0,


    [:else, 2, 34, 65, 34, 67]=>2,


    }}

    View full-size slide

  151. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }

    View full-size slide

  152. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File

    View full-size slide

  153. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File mode

    View full-size slide

  154. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File mode
    conditional

    View full-size slide

  155. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File mode
    conditional
    branch

    View full-size slide

  156. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File mode
    conditional
    branch
    branch

    View full-size slide

  157. kevinjmurphy.com
    Branches
    /Bones
    {


    "branches_bones.rb" => { :branches =>


    {[:if, 0, 34, 25, 34, 67] => {


    [:then, 1, 34, 60, 34, 62] => 0,


    [:else, 2, 34, 65, 34, 67] => 2,


    }}


    }


    }
    File mode
    conditional
    branch
    branch

    View full-size slide

  158. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0

    View full-size slide

  159. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    count

    View full-size slide

  160. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch count

    View full-size slide

  161. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch count
    id

    View full-size slide

  162. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch start line count
    id

    View full-size slide

  163. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch start line
    start column
    count
    id

    View full-size slide

  164. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch start line
    start column
    end line
    count
    id

    View full-size slide

  165. kevinjmurphy.com
    Branches
    /Bones
    [:then, 1, 34, 60, 34, 62] => 0
    branch start line
    start column
    end line
    end column
    count
    id

    View full-size slide

  166. kevinjmurphy.com
    Branches
    /Bones
    class BranchesBones < Song


    def chorus(number)


    echo_intensity = number.positive? && number.even? ? 10 : 30





    Lyric.new(line: line, effect: :echo, effect_level: echo_intensity)






    32


    33


    34


    35


    60
    62

    View full-size slide

  167. kevinjmurphy.com
    Branches
    /Bones
    class BranchesBones < Song


    def initialize


    notes = verse_1 + chorus(0) + verse_2 + chorus(1) + outro


    end


    def chorus(number)


    echo_intensity = number.positive? && number.even? ? 10 : 30


    end

    View full-size slide

  168. kevinjmurphy.com
    Branches
    /Bones
    class BranchesBones < Song


    def initialize


    notes = verse_1 + chorus(0) + verse_2 + chorus(1) + outro


    end


    def chorus(number)


    echo_intensity = number.positive? && number.even? ? 10 : 30


    end

    View full-size slide

  169. kevinjmurphy.com
    Branches
    /Bones
    class BranchesBones < Song


    def initialize


    notes = verse_1 + chorus(1) + verse_2 + chorus(2) + outro


    end


    def chorus(number)


    echo_intensity = number.positive? && number.even? ? 10 : 30


    end

    View full-size slide

  170. kevinjmurphy.com
    Branches
    /Bones
    song_coverage[:branches]


    => {[:if, 0, 34, 25, 34, 67]=>{


    [:then, 1, 34, 60, 34, 62]=>1,


    [:else, 2, 34, 65, 34, 67]=>1,


    }}

    View full-size slide

  171. kevinjmurphy.com
    Branches
    /Bones
    Nine Inch Nails


    CC BY-NC-SA 2.0

    View full-size slide

  172. kevinjmurphy.com
    {


    }
    coverage.summary

    View full-size slide

  173. kevinjmurphy.com
    {


    lines: "how many times was each line executed?",


    }
    coverage.summary

    View full-size slide

  174. kevinjmurphy.com
    {


    lines: "how many times was each line executed?",


    oneshot_lines: "which lines were executed?",


    }
    coverage.summary

    View full-size slide

  175. kevinjmurphy.com
    {


    lines: "how many times was each line executed?",


    oneshot_lines: "which lines were executed?",


    methods: "how many times was each method executed?",


    }
    coverage.summary

    View full-size slide

  176. kevinjmurphy.com
    {


    lines: "how many times was each line executed?",


    oneshot_lines: "which lines were executed?",


    methods: "how many times was each method executed?",


    branches: "how many times was each branch executed?",


    }
    coverage.summary

    View full-size slide

  177. kevinjmurphy.com
    Supporti
    ng I
    nstruments
    SimpleCov


    Coverband


    Nine Inch Nails CC BY-NC-SA 2.0

    View full-size slide

  178. kevinjmurphy.com
    kevinjmurphy.com/coverage


    newsletter.kevinjmurphy.com


    Nine Inch Nails CC BY-NC-SA 2.0
    @[email protected]

    View full-size slide

  179. kevinjmurphy.com
    kevinjmurphy.com/coverage


    newsletter.kevinjmurphy.com


    Nine Inch Nails CC BY-NC-SA 2.0
    @[email protected]

    View full-size slide