File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -729,7 +729,7 @@ def expected_for_failure_message
729729 end
730730
731731 def match_array ( items )
732- BuiltIn ::MatchArray . new ( items )
732+ BuiltIn ::MatchArray . new ( items . is_a? ( String ) ? [ items ] : items )
733733 end
734734 alias_matcher :an_array_matching , :match_array
735735 end
Original file line number Diff line number Diff line change 369369 end
370370 end
371371 end
372+
373+ context "when the input value is a string" do
374+ it "produces the correct failure message when used in the positive" do
375+ as_both_colored_and_uncolored do |color_enabled |
376+ snippet = <<~TEST . strip
377+ expected = "Einie"
378+ actual = ["Marty", "Jennifer", "Doc"]
379+ expect(actual).to match_array(expected)
380+ TEST
381+ program = make_plain_test_program (
382+ snippet ,
383+ color_enabled : color_enabled ,
384+ )
385+
386+ expected_output = build_expected_output (
387+ color_enabled : color_enabled ,
388+ snippet : %|expect(actual).to match_array(expected)| ,
389+ expectation : proc {
390+ line do
391+ plain "Expected "
392+ beta %|["Marty", "Jennifer", "Doc"]|
393+ plain " to match array with "
394+ alpha %|"Einie"|
395+ plain "."
396+ end
397+ } ,
398+ diff : proc {
399+ plain_line %| [|
400+ plain_line %| "Marty",|
401+ plain_line %| "Jennifer",|
402+ plain_line %| "Doc",|
403+ alpha_line %|- "Einie"|
404+ plain_line %| ]|
405+ } ,
406+ )
407+
408+ expect ( program ) .
409+ to produce_output_when_run ( expected_output ) .
410+ in_color ( color_enabled )
411+ end
412+ end
413+ end
372414end
You can’t perform that action at this time.
0 commit comments