Contents

Pretty-print with source

Kernel#pp, if given a block, prints the source for the block and then the pretty-printed result of running the block.

Scenario: Label and pretty-print an object

  • Given a file with:
    ruby
    require "cute_print"
    a = [
      "Once upon a time there were four little Rabbits, and their names were",
      "Flopsy,",
      "Mopsy,",
      "Cotton-tail, and",
      "Peter.",
    ]
    qq {a}
  • Then stderr should be
    a is ["Once upon a time there were four little Rabbits, and their names were",
          "Flopsy,",
          "Mopsy,",
          "Cotton-tail, and",
          "Peter."]
    

Source: features/pretty_print/pretty_print_with_source.feature at commit e8ebd2a4, Cute Print (MIT license).