You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RSpec's built-in eq matcher is very useful for comparing two strings.
The Diff message for failing test allows developers to quickly find bugs especially for large size text.
However, I have found a confusing message when the diff is a trailing new line.
It says:
<The diff is empty, are your objects producing identical `#inspect` output?>
require'rspec'deflines_to_text(*args)args.join("\n")endRSpec.describe'#lines_to_text'dosubject{lines_to_text('foo','bar','baz')}context'when there is diff inside string'doit'shows diff elegantly'doexpect(subject).toeq"foo\n\nbar\nbaz"endendcontext'when there is a diff after the string'doit'shows somewhat confusing message'doexpect(subject).toeq<<~EXPECTED foo bar baz EXPECTEDendendend
Expected behavior
For the second test:
2) #lines_to_text when there is a diff after the string shows somewhat confusing message
Failure/Error:
expect(subject).to eq <<~EXPECTED
foo
bar
baz
EXPECTED
expected: "foo\nbar\nbaz\n"
got: "foo\nbar\nbaz"
(compared using ==)
Diff:
@@ -1,3 +1,4 @@
foo
bar
baz
+
# ./spec/sample_spec.rb:19:in `block (3 levels) in <top (required)>'
Actual behavior
For the second test:
2) #lines_to_text when there is a diff after the string shows somewhat confusing message
Failure/Error:
expect(subject).to eq <<~EXPECTED
foo
bar
baz
EXPECTED
expected: "foo\nbar\nbaz\n"
got: "foo\nbar\nbaz"
(compared using ==)
Diff:
<The diff is empty, are your objects producing identical `#inspect` output?>
# ./spec/sample_spec.rb:19:in `block (3 levels) in <top (required)>'
The text was updated successfully, but these errors were encountered:
Thanks, this is a duplicate of #570 as you linked to, as the trailing new line produces no diff you get this output. The underlying cause is, (again as you linked to) rspec/rspec-support#70, free free to attempt a PR to fix that.
RSpec's built-in
eq
matcher is very useful for comparing two strings.The Diff message for failing test allows developers to quickly find bugs especially for large size text.
However, I have found a confusing message when the diff is a trailing new line.
It says:
Here are the related issues.
Your environment
Steps to reproduce
Following is the test code to reproduce this.
Expected behavior
For the second test:
Actual behavior
For the second test:
The text was updated successfully, but these errors were encountered: