Sha256: f49310fa852652bb652af1cc235449b5d0180ad365937e9cefdc3af5aa1f2e93

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

Feature: Inspect a call chain

  Call chains (aka "train wrecks") can be a bother to debug.
  Kernel#tapq prints a value in a call chain and then continues the
  chain.

  Scenario: Without source position
    Given a file with:
      """
      require "cute_print"
      puts ["1", "2"].map(&:to_i).tapq.inject(:+)
      """
    Then stdout should be
      """
      3

      """
    And stderr should be
      """
      [1, 2]

      """

  Scenario: With source position
    Given a file named "example.rb" with:
      """
      require "cute_print"
      puts ["1", "2"].map(&:to_i).tapql.inject(:+)
      """
    Then stdout should be
      """
      3

      """
    And stderr should be
      """
      example.rb:2: [1, 2]

      """

  Scenario: Pretty print
    Given a file with:
      """
      require "cute_print"
      a = [
        "Once upon a time there were four little Rabbits, and their names were",
        "Flopsy,",
        "Mopsy,",
        "Cotton-tail, and",
        "Peter.",
      ]
      puts a.tapqq.map(&:size).inject(&:+)
      """
    Then stdout should be
      """
      104

      """
    And stderr should be
      """
      ["Once upon a time there were four little Rabbits, and their names were",
       "Flopsy,",
       "Mopsy,",
       "Cotton-tail, and",
       "Peter."]
 
      """

  Scenario: Pretty print with source location
    Given a file with:
      """
      require "cute_print"
      a = [
        "Once upon a time there were four little Rabbits, and their names were",
        "Flopsy,",
        "Mopsy,",
        "Cotton-tail, and",
        "Peter.",
      ]
      puts a.tapqql.map(&:size).inject(&:+)
      """
    Then stdout should be
      """
      104

      """
    And stderr should be
      """
      example.rb:9:
        ["Once upon a time there were four little Rabbits, and their names were",
         "Flopsy,",
         "Mopsy,",
         "Cotton-tail, and",
         "Peter."]
 
      """

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cute_print-1.1.4 features/call_chain.feature
cute_print-1.1.3 features/call_chain.feature
cute_print-1.1.2 features/call_chain.feature
cute_print-1.1.1 features/call_chain.feature
cute_print-1.1.0 features/call_chain.feature
cute_print-1.0.1 features/call_chain.feature
cute_print-1.0.0 features/call_chain.feature
cute_print-0.4.0 features/call_chain.feature