The message lines include two parts:

   - The english language parts (like "Failure/Error", and the failure
   message from the matcher)
   - The extracted code snippet (the `TestClass.test_method` part).

For the extracted code snippet, we use coderay to syntax highlight it if
that gem can be loaded.  For the english language part, RSpec applies the
color highlighting (but only when you call `colorized_message_lines`).

We should probably fix `message_lines` so that it doesn't apply coderay to
the snippet, while `colorized_message_lines` should.  Can you open an issue
on rspec-core about this?

Myron

On Thu, Sep 14, 2017 at 10:06 PM, Dylan Reichstadt <
[email protected]> wrote:

> Hey All,
>
> I'm trying to export data from RSpec, including the failing lines of code.
> In the FailedExampleNotification
> <http://www.rubydoc.info/gems/rspec-core/RSpec/Core/Notifications/FailedExampleNotification>,
> I noticed there were two methods:
>
>    - message_lines
>    - colorized_message_lines.
>
> Despite the name differences, both of these methods look to return ANSI
> color characters, with message_lines slightly less (see below). I was
> expecting colorized_message_lines to do that, but not message_lines.
>
> Is there a public method that exposes this data without the ANSI? I'll
> look to regex them out, but if there's another method that's more reliable,
> I would love to know.
>
> Thanks!
>
> RSpec Version: 3.6.0
>
>
> notification.message_lines
> => ["Failure/Error: \e[0m\e[1;34;4mTestClass\e[0m.test_method",
>  "  expected to find css \"thisisatest\" but there were no matches"]
>
> notification.colorized_message_lines
> => ["\e[31mFailure/Error: \e[0m\e[1;34;4mTestClass\e[0m.test_method\e[0m",
>  "\e[31m  expected to find css \"gjiegeij\" but there were no
> matches\e[0m"]
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/rspec/3f5fd029-9bed-4dde-bac5-f76fe0d9ce9c%40googlegroups.com
> <https://groups.google.com/d/msgid/rspec/3f5fd029-9bed-4dde-bac5-f76fe0d9ce9c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CADUxQmtiSYvKvfc2dWDxCRMcoCDRfV0G_iyV8i5FrjF%3D_tQO2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to