Two tests are breaking, and I kind of understand why, but I'm
not sure what to do about it. Figured I should commit and send
a PR in hopes of another brain being able to help me out :)
There are sporadic failures with some of the tests (seems to be isolated to the
code that uses `Pry.config.commands`). Passing `binding` to `pry_eval` seems to
be fixing them. To be quite fair, I'm not sure why that happens but it feels
like the right fix because we do the same in many other tests.
This is not perfect but this reset `Pry.line_buffer`. `pry_eval` writes to it
and makes some tests fail randomly. This should probably be rewritten properly
but this hack will do to make the tests pass.
A bunch of tests were order-dependent and weren't cleaning up properly after
they're executed. This results in complications with #2055 where we want to
randomise our test suite.
With this change every test defines what it needs and then cleans up properly,
instead of relying on the global space and fixtures.
P.S. The specs are still quite messy but this change is a step in the right
direction.
This spec was failing for me locally (but worked well on Circle). The reason
is that `XDG_CONFIG_HOME` is set for me and takes precedence. Therefore, the fix
would be to unset it for the test.
References #2054
Using XDG_* paths (if set) with preference higher than the
home dir, for pry config and history files.
Testing: ran `bundle exec rspec`, observed the tests pass.
Fixes#1991 (Pry in a non-stdin/stdout PTY uses incorrect window size on
non-JRuby platforms)
`Pry::Terminal` was built without custom outputs in mind. We would always assume
that `$stdout` is what the user wants. This contradicted the `output` config
option.
Thanks to `Pry::Output`, which we use internally, we can decorate the output
that the user passes us with "size" methods. If we do that, we get improved
output support for free, so that PTY's `slave` can be passed to Pry and would be
able to determine its size correctly (example from #1991).
I do suspect that there are still some gotchas. Some commands or portions of
code may still be assuming that `$stdout` is the only possible option. This has
to be addressed separately, in the scope of
https://github.com/pry/pry/issues/1988. The more tests we add, the easier it
will be to uncover those spots.
Surely, `boxed_io` sounds way cooler than plain and boring `output` but I don't
think it helps for understanding the code. Although it *is* an IO object, we
treat it as output. Hence, it should be output (no boxes involved).
To be perfectly honest, I have no idea why these methods have exclamation
marks. Maybe because they may require `io/console`? Even then, there's nothing
dangerous in this.
Although this is more verbose now, it looks more like proper unit tests. The
tester API needs to be revamped because `tester.eval` is *not* unit testing.