Truncate error string "actual" output on ShouldContain to 100 chars #37

Closed
xerxesb opened this Issue Nov 1, 2011 · 7 comments

Comments

Projects
None yet
4 participants
@xerxesb
Owner

xerxesb commented Nov 1, 2011

When calling a Should* method on a string argument for text matching, the error message will print the full content of the actual value. Most of the time this is fine as the content being asserted is usually small(ish).

Sometimes (particularly in the case of ShouldContain) there might be a larger content block being asserted against which means the error message will put out a lot of content, mostly unnecessary.

This change is to truncate the "actual" output after a string assertion has failed and limit to 100 chars. The idea was born out of Issue #35, and the number of 100 characters was an arbitrary number I pulled out of my arse. (i.e. i'm happy to re-evaluate if 100 seems insufficient)

@benjamine

This comment has been minimized.

Show comment Hide comment
@benjamine

benjamine Nov 2, 2011

great! 100 is perfect ;)
thanks

great! 100 is perfect ;)
thanks

@whatupdave

This comment has been minimized.

Show comment Hide comment
@whatupdave

whatupdave Nov 3, 2011

Owner

This would be good, It should only show the areas of text that are different and snip the other parts out.

Owner

whatupdave commented Nov 3, 2011

This would be good, It should only show the areas of text that are different and snip the other parts out.

@benjamine

This comment has been minimized.

Show comment Hide comment
@benjamine

benjamine Nov 3, 2011

Dave, I don't think that make sense for ShouldContains(), as the different part would be the whole string!.
Printing a text diff could make sense on ShouldBe() when comparing 2 large strings (eg. qunit does that), could be opened as other issue.

Dave, I don't think that make sense for ShouldContains(), as the different part would be the whole string!.
Printing a text diff could make sense on ShouldBe() when comparing 2 large strings (eg. qunit does that), could be opened as other issue.

@whatupdave

This comment has been minimized.

Show comment Hide comment
@whatupdave

whatupdave Nov 4, 2011

Owner

Yep, that wouldn't pertain to ShouldContain, but it would definitely be handy for ShouldBe and ShouldBeCloseTo. I'll open a new issue

Owner

whatupdave commented Nov 4, 2011

Yep, that wouldn't pertain to ShouldContain, but it would definitely be handy for ShouldBe and ShouldBeCloseTo. I'll open a new issue

@mattdotmatt

This comment has been minimized.

Show comment Hide comment
@mattdotmatt

mattdotmatt Apr 2, 2012

Contributor

Was a new issue opened for this?

Is the expected behaviour still:
ShouldContains: Truncate the "actual" output after a string assertion has failed and limit to 100 chars.
ShouldBe/ShouldBeClose: Show text diff and limit this to 100 chars if necessary.

Contributor

mattdotmatt commented Apr 2, 2012

Was a new issue opened for this?

Is the expected behaviour still:
ShouldContains: Truncate the "actual" output after a string assertion has failed and limit to 100 chars.
ShouldBe/ShouldBeClose: Show text diff and limit this to 100 chars if necessary.

@xerxesb

This comment has been minimized.

Show comment Hide comment
@xerxesb

xerxesb Apr 2, 2012

Owner

Doesn't look like it. Sorry - I havent had much opportunity to look into detailed features in Shouldly for some time :(

This task is still to limit the output on ShouldContain to 100 chars as it still should restrict the context. I'll create a second issue now with some more info for ShouldBe.

Cheers

Owner

xerxesb commented Apr 2, 2012

Doesn't look like it. Sorry - I havent had much opportunity to look into detailed features in Shouldly for some time :(

This task is still to limit the output on ShouldContain to 100 chars as it still should restrict the context. I'll create a second issue now with some more info for ShouldBe.

Cheers

xerxesb added a commit that referenced this issue Apr 21, 2012

Issue #37 - Truncate error string "actual" output on ShouldContain to…
… 100 chars

Restrict actual part of error message returned from ShouldContain to maximum of 100 characters

Xerxes: Disabled push to GitHub due to breaks in net/ruby-github. Will
investigate later
@xerxesb

This comment has been minimized.

Show comment Hide comment
@xerxesb

xerxesb Apr 21, 2012

Owner

Integrated and released as v1.1.1.1

Owner

xerxesb commented Apr 21, 2012

Integrated and released as v1.1.1.1

@xerxesb xerxesb closed this Apr 21, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment