1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
Commit graph

9 commits

Author SHA1 Message Date
Kyrylo Silin
b3f71bc3b6 Don't use Enumerators in unit tests
In previous commit (5d983f49a2) I added
Enumerators to unit tests. It appears that Enumerator is not available
for Ruby 1.8.7 and friends. So, let's rewrite the related to Enumerator
code and hard-code everything again.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-07-12 00:32:35 +03:00
Kyrylo Silin
5d983f49a2 Use Pad instead of global variables in tests
First of all, rewrite `test_cd.rb`, so instead of hard-coded so called
"binding stack" and "old stack" strings with indices (`bs1`, `os2`,
etc.) we use Enumerator that lazily creates these strings for us.
Also, implement exactly the same Enumerator for the
`test_command_integration.rb`, because we use there a lot of operations
with binding stack.

Next, replace all unwanted use of global variables in other unit tests
with Pad.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-07-11 21:50:44 +03:00
Kyrylo Silin
3e1b8f5ada Add "path with an exceptional situatuion" test
Implement a unit test which tests the situation, when a user's input is
a complex path that raises an execption. For example, the following
input raises NameError: `cd :toplevel`, `cd 1/2/hi`. We should ensure
that after the second expression our current binding is still
`:toplevel`.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-06-30 19:59:23 +03:00
Kyrylo Silin
614b219265 Make tests for cd command use Pad
Currently, unit tests for `cd` command are varied in their
implementation. Standardize them by using freshly introduced ScratchPad.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-06-27 18:01:29 +03:00
Kyrylo Silin
367e076670 Change behavior of cd - command
Since banister begged me to do that... completely rewrite `cd -`
command (implemetation is much simpler now).

This commit brings such changes:

  * completely rewrite behavior of `cd -` command;

  * implement ScratchPad aka Pad for unit testing purposes (by
    banister);

  * use Pad riches in the unit tests for `cd -` command;

  * remove verbose and clunky unit tests;

This commit brings new meaning to the `cd -` command. The main
difference is that the new command saves entire binding stack, not just
the last binding. Let me show you an example of the variance between
these two implemetations:

  * Old `cd -` implementation saves *only* last binding. With our next
    `cd -` invocation our interjacent results are lost:
      [1] pry(main)> cd 1/2/3/../4
      [2] pry(4):3> cd -
      [3] pry(main)> cd -
      [4] pry(4):1> nesting
      Nesting status:
      --
      0. main (Pry top level)
      1. 4

      Also, there are a few bugs in old `cd -` command:

        * you type `cd :foo`, `cd 1/2/3` and `cd -`. The last command
          relocates you to the scope of `3` (leaves you where you was),
          when `:foo` is expected;

        * you type `cd :foo`, `cd 1/2/3/../4`, `cd -`. The last command
          relocates you to the scope of `3`, when `:foo` is expected.

  * New and shiny `cd -` is devoid of those shortcomings:
      [1] pry(main)> cd 1/2/3/../4
      [2] pry(4):3> cd -
      [3] pry(main)> cd -
      [4] pry(4):3> nesting
      Nesting status:
      --
      0. main (Pry top level)
      1. 1
      2. 2
      3. 4

As I said before, this solution is *much* simpler and less error-prone.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-06-27 14:54:07 +03:00
Kyrylo Silin
3e56239d50 Implement cd - command
The `cd -` command allows a user to toggle between last two scopes.

Example:

  [1] pry(main)> cd :foo
  [2] pry(:foo):1> cd :bar
  [3] pry(:bar):2> cd -
           ^ save :bar and toggle
  [4] pry(:foo):1> cd 44
           ^ we are back at foo
  [5] pry(44):2> cd ..
  [6] pry(:foo):1> cd ..
  [7] pry(main)> cd -
           ^ save main and toggle
  [8] pry(:foo):1>
           ^ we are back at foo

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
2012-06-19 16:43:46 +02:00
Kyrylo Silin
8f3e4555ba Tidy up tests and remove some repeating code
Clean up repeating code on the subject of str_output variable. Fix
indentation in some files and restructure some tests, in order to
ease parsing of files by an eye.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
2012-06-11 19:33:04 +02:00
Kyrylo Silin
8914dbf205 Break off Cd tests from Context
Our unit tests for `cd` command are in 'test_context.rb' file. Since we
have a separate 'test_cd.rb' file in the same directory, let's make use
of it.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-06-10 16:31:06 +03:00
Jordon Bedwell
d4de593f08 Partially fix #516 (see list of notes for more)
* Move is_a? to == in pry_class.rb
* Add  test for __binding__ for @ConradIrwin.
* Add regression test to prevent us from using is_a?(Binding).
2012-04-05 14:04:20 -05:00