Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit b5f29f2

Browse files
committed
Merge pull request #69 from phiggins/dont-leak-differ-implementation-details
Call #to_s on output to avoid leaking Differ's implementation details.
2 parents 6cd89ef + c983ebe commit b5f29f2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/rspec/support/differ.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def diff(actual, expected)
1919
end
2020
end
2121

22-
diff
22+
diff.to_s
2323
end
2424

2525
def diff_as_string(actual, expected)

spec/rspec/support/differ_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,16 @@ def inspect
251251
expect(diff).to be_empty
252252
end
253253

254+
it "returns a String if no diff is returned" do
255+
diff = differ.diff 1, 2
256+
expect(diff).to be_a(String)
257+
end
258+
259+
it "returns a String if a diff is performed" do
260+
diff = differ.diff "a\n", "b\n"
261+
expect(diff).to be_a(String)
262+
end
263+
254264
context "with :object_preparer option set" do
255265
let(:differ) do
256266
RSpec::Support::Differ.new(:object_preparer => lambda { |s| s.to_s.reverse })

0 commit comments

Comments
 (0)