Skip to content
This repository
Browse code

fix bug diffing single strings with multiline strings

  • Loading branch information...
commit 07dd19c8a90167c499460c3f8d4ab8d6642fe23a 1 parent e290fe3
David Chelimsky authored
2  lib/rspec/matchers/built_in/include.rb
@@ -5,7 +5,7 @@ class Include
5 5
         include BaseMatcher
6 6
 
7 7
         def initialize(*expected)
8  
-          super(expected)
  8
+          expected.length == 1 && String === expected.first ? super(expected.first) : super(expected)
9 9
         end
10 10
 
11 11
         def matches?(actual)
10  spec/rspec/matchers/include_spec.rb
@@ -11,11 +11,21 @@
11 11
         "abc".should include("a")
12 12
       end
13 13
 
  14
+      it "passes if multiline target includes expected" do
  15
+        "\nabc\ndef".should include("a")
  16
+      end
  17
+
14 18
       it "fails if target does not include expected" do
15 19
         lambda {
16 20
           "abc".should include("d")
17 21
         }.should fail_matching("expected \"abc\" to include \"d\"")
18 22
       end
  23
+
  24
+      it "fails if multiline target does not include expected" do
  25
+        lambda {
  26
+          "abc\ndef".should include("g")
  27
+        }.should raise_exception(/expected "abc\\ndef" to include "g"\nDiff/m)
  28
+      end
19 29
     end
20 30
 
21 31
     context "for an array target" do

0 notes on commit 07dd19c

Please sign in to comment.
Something went wrong with that request. Please try again.