Skip to content

Truncate too long lines #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Truncate too long lines #24

wants to merge 1 commit into from

Conversation

uiur
Copy link

@uiur uiur commented Dec 3, 2017

large_object.inspect returns a very long message. It makes an assertion message hard to read.

In Rails, ActionDispatch::TestResponse is large and its inspect is over 10000 characters (in my environment)

    assert { @response.status == status_code(:forbidden) }
             |                |  |
             |                |  403
             |                false
             #<ActionDispatch::TestResponse:0x00007fc8bd704eb8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x00007fc8bd704e18>, @header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff", "Content-Type"=>"application/json; charset=utf-8", "ETag"=>"W/\"c3ab8ff13720e8ad9047dd39466b3c89\"", "Cache-Control"=>"max-age=0, private, must-revalidate", "X-Request-Id"=>"3c9a5c24-962d-4e2e-9d55-3d4f3fa5c0c0", "X-Runtime"=>"0.078733", "Content-Length"=>"6"}, @stream=#<ActionDispatch::Response::Buffer:0x00007fc8bd704da0 @response=#<ActionDispatch::TestResponse:0x00007fc8bd704eb8 ...>, @buf=["foobar"], @closed=false, @str_body=nil>, @status=200, @cv=#<MonitorMixin::ConditionVariable:0x00007fc8bd704d78 @monitor=#<ActionDispatch::TestResponse:0x00007fc8bd704eb8 ...>, @cond=#<Thread::ConditionVariable:0x00007fc8bd704d50>>, @committed=false, @sending=false, @sent=false, @cache_control={:max_age=>"0", :private=>true, :must_revalidate=>true}...

This change truncates each line and make messages more readable.

How do you think?

@k-tsj
Copy link
Member

k-tsj commented Dec 10, 2017

Thanks for your PR.

I am neutral on your proposal. However, I have the following concerns.

  • Should this feature be enabled by default? It may remove useful information from output message.
  • Should the maximum width be statically decided?

Let me think about it for a while.

BTW, power_assert provides _use_pp option.
It is still an experimental feature (so the option name has _ prefix), but I will promote it as an official one.
It may help you.

require 'power_assert'

PowerAssert.configure do |c|
  c._use_pp = true
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants