Skip to content

Add failing specs for multi-line array/hash literal snippet extraction.

Created by: myronmarston

@yujinakayama, I found another case where the snippet extractor does not return the entire expression: when the failure happens in the middle of a multi-line array or hash literal. This time I was able to add failing specs for this case. Can you take a look?

Failures:

  1) RSpec::Core::Formatters::SnippetExtractor in Ripper supported environment when the failing expression is in the middle of a multi-line hash literal returns the entire hash literal
     Failure/Error:
       expect(expression_lines).to eq([
        '          {',
        '            foo: 1,',
        '            bar: do_something_fail,',
        '            baz: 3',
        '          }'
       ])

       expected: ["          {", "            foo: 1,", "            bar: do_something_fail,", "            baz: 3", "          }"]
            got: ["            bar: do_something_fail,"]

       (compared using ==)
     # ./spec/rspec/core/formatters/snippet_extractor_spec.rb:277:in `block (4 levels) in <module:Formatters>'
     # ./spec/support/sandboxing.rb:14:in `block (3 levels) in <top (required)>'
     # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'

  2) RSpec::Core::Formatters::SnippetExtractor in Ripper supported environment when the failing expression is in the middle of a multi-line array literal returns the entire array literal
     Failure/Error:
       expect(expression_lines).to eq([
        '          [',
        '            1,',
        '            do_something_fail,',
        '            3',
        '          ]'
       ])

       expected: ["          [", "            1,", "            do_something_fail,", "            3", "          ]"]
            got: ["            do_something_fail,"]

       (compared using ==)
     # ./spec/rspec/core/formatters/snippet_extractor_spec.rb:297:in `block (4 levels) in <module:Formatters>'
     # ./spec/support/sandboxing.rb:14:in `block (3 levels) in <top (required)>'
     # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'

BTW, nice work on the structure of the snippet extractor specs -- it was very easy to add these :).

Merge request reports