Skip to content

If a trailing newline is missing from actual vs. expected, it is not shown in the diff #184

@mcmire

Description

@mcmire

Here's some example output from RSpec:

  1) Albatross::Cli given --help prints the help screen
     Failure/Error:
             expect(stdout.string).to eq(<<-OUTPUT)
       Commands for working with the development environment.

       #{colorize(:bold, "USAGE")}

       executable COMMAND [OPTIONS]

       #{colorize(:bold, "COMMANDS")}

       init - Initialize development environment

       Expected "Commands for working with the development environment.\n\n\e[1mUSAGE\e[0m\n\nexecutable COMMAND [OPTIONS]\n\n\e[1mCOMMANDS\e[0m\n\ninit - Initialize development environment\n run - Run a command within a Ruby version\n\n\e[1mOPTIONS\e[0m\n\n    -h, --help                       You're looking at it ;)\n\n"
          to eq "Commands for working with the development environment.\n\n\e[1mUSAGE\e[0m\n\nexecutable COMMAND [OPTIONS]\n\n\e[1mCOMMANDS\e[0m\n\ninit - Initialize development environment\n run - Run a command within a Ruby version\n\n\e[1mOPTIONS\e[0m\n\n    -h, --help                       You're looking at it ;)\n"

       Diff:

       ┌ (Key) ──────────────────────────┐
       │ ‹-› in expected, not in actual  │
       │ ‹+› in actual, not in expected  │
       │ ‹ › in both expected and actual │
       └─────────────────────────────────┘

         Commands for working with the development environment.\n
         \e[1mUSAGE\e[0m\n
         executable COMMAND [OPTIONS]\n
         \e[1mCOMMANDS\e[0m\n
         init - Initialize development environment\n
          run - Run a command within a Ruby version\n
         \e[1mOPTIONS\e[0m\n
             -h, --help                       You're looking at it ;)\n

Here, actual has an extra newline, whereas expected does not. However, this isn't obvious, because the diff doesn't have any - or + lines whatsoever.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions