summaryrefslogtreecommitdiff
path: root/spec
Commit message (Collapse)AuthorAgeFilesLines
...
* spec_helper: reset Pry defaults after each testKyrylo Silin2019-06-151-0/+1
| | | | | | 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.
* spec/code_object: fix broken 'class method lookup' testKyrylo Silin2019-06-151-2/+4
|
* spec/editor: make specs order-independent (and sturdier)Kyrylo Silin2019-06-151-5/+16
|
* spec_helper: randomize testsKyrylo Silin2019-06-151-0/+2
|
* spec/commands/show_{doc,source}: refactor to be order independentKyrylo Silin2019-06-153-667/+933
| | | | | | | | | | | | 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.
* spec/config: fix flaky testKyrylo Silin2019-06-091-2/+6
| | | | | | 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.
* Use Pry::Env where it makes senseKyrylo Silin2019-06-093-32/+31
|
* Add Pry::EnvKyrylo Silin2019-06-091-0/+26
| | | | Env is a helper module to work with environment variables.
* Close #2054 - prefer XDG_* paths (if set)A. Nackov2019-06-052-8/+26
| | | | | | | | | 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.
* MemoizedValue memoizes nil results (#2053)Josh Cheek2019-06-031-3/+13
| | | | I moved the existing `subject` into the test because it didn't make sense for the second test I added.
* Fix tests that fail based on user's environment (#2047)Josh Cheek2019-06-021-10/+18
| | | | | These tests would fail on my machine. I think it is because I have a ~/.pry_history file. I modified them to not depend on the state of my machine.
* Remove all remaining `.should`s from the testsJosh Cheek2019-05-307-41/+32
|
* spec/pry_defaults: silence unwanted deprecation warningstest-suite-silence-warningsKyrylo Silin2019-05-281-0/+3
|
* Merge Pry::Terminal with Pry::OutputKyrylo Silin2019-05-262-1/+172
| | | | | | | | | | | | | | | | | | | | 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.
* Add unit tests for Pry::OutputKyrylo Silin2019-05-261-0/+197
|
* commands/wtf: add the --code flagKyrylo Silin2019-05-121-0/+51
| | | | Fixes #1876 (Make `wtf` show code)
* commands/wtf_spec: refactor unit testsKyrylo Silin2019-05-111-24/+149
| | | | | 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.
* Fix offences of the Style/FrozenStringLiteralComment copKyrylo Silin2019-05-086-23/+29
| | | | | Fixes #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations)
* rubocop: enable the Style/FrozenStringLiteralComment copKyrylo Silin2019-05-0882-0/+164
| | | | This will greatly ease Pry support on Ruby 3.0 (when it's out).
* control_d_handler: don't mutate eval_string within the handlerKyrylo Silin2019-05-043-14/+93
| | | | | | | | | | | | | | | | | This is a preparational step for #1824 (Enabling `# frozen_string_literal: true` in `~/.pryc` crashes most operations) Alternative to https://github.com/pry/pry/pull/2030 (config: delete the `control_d_handler` option) We had to jump a few hoops to change how the handler works. The problem is that mutation is the default expected behaviour. Therefore, we had to change its API. There's no need to pass `eval_string` because `pry_instance` already has it as an attribute. `config.control_d_handler` is a proxy proc, to preserve backwards compatibility with users of old signature (one known user is Pry Byebug). The handler will emit a warning if the old signature is used.
* warning: print file and line of the calling frameKyrylo Silin2019-05-041-4/+2
| | | | | | We want to print the calling frame, so we can point out who exactly triggered it. The current behaviour is less useful (we print the line that called the warning).
* Add Pry::WarningKyrylo Silin2019-05-041-0/+10
| | | | | | Quite often, when we deprecate APIs, we want to print a warning. Such a warning would be hard to track without a file and line location. We are trying to be a good citizen and print warnings like Ruby does it.
* config: add `rc_file` that allows specifying `pryrc` fileKyrylo Silin2019-05-033-3/+44
| | | | | | Keeping this in a constant makes it really hard to test. Moving it to the config and making it configurable seems to be sensible. Now we have a new option and a lot of tests.
* Refactor ConfigKyrylo Silin2019-05-0215-305/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #1843 (Rework the Pry config) There are a few breaking changes. They are mostly minor, so I decided not to indroduce deprecations because it will considerable slow things down. Key changes: * `Pry.lazy` was replaced with `Pry::Configuration::LazyValue` The config accepts three values now `LazyValue`, `MemoizedValue` and simply `Value`. The main difference is that: - `Value` is any value, including procs (so that an option returns a raw proc) - `LazyValue` is a proc that is call on every invocation of an option - `MemoizedValue` is a value that is called only once (and then the option always returns the return value of the ) * `Pry.config.history` was a meta-option that held suboptions. However, the new config doesn't permit that (unless you know what you do) Instead, we introduce a few options. For example: - `Pry.config.history.histignore` becomes `Pry.config.history_ignorelist` - `Pry.config.history.file` becomes `Pry.config.history_file` - and so on This was done so we can simplify configuration merging. Inlining option makes configuration implementation simpler, without losing much. The rule is that you want to keep your options under your prefix (if you are a plugin). Therefore, say, `Pry.config.pry_rescue.*` should be `Pry.config.pry_rescue_*` if you need merging. The rest should behave in a similar fashion (and I rely heavily on our test suite to claim so).
* Reduce the influence of Pry::ConfigKyrylo Silin2019-04-303-5/+4
| | | | | | | This is one of preliminary steps for #1843 (Rework the Pry config). In this commit we replace calls to `Pry::Config` where possible, therefore we reduce coupling between the config and other components.
* spec/command: fix spec on 1.9.3Kyrylo Silin2019-04-291-2/+2
| | | | | The new command state implementation returns an OpenStruct. On Ruby 1.9 OpenStruct doesn't support `#[]`.
* pry_instance: factor out command state to be globalcommand-global-stateKyrylo Silin2019-04-295-10/+61
| | | | | | | | | | | | | | | | | This change is aimed to simplify #1843 (Rework the Pry config). Current command state implementation gets in the way. We would like to simplify the Config class. The current implementation penetrates Pry codebase everywhere, and during my rework of the config I discovered that `watch` uses global command state. It means the state should survive `Pry.new` calls. With my (unpublished yet) implementation, the `watch` command fails to do so. I realised that we can refactor command state implementation to be global. It makes sense to me and also helps with the Config refactoring. With help of a dedicated class we can easily manage the command state (resetting).
* config: factor out control_d_handler to ControlDHandlerKyrylo Silin2019-04-151-47/+40
|
* config: factor out 'system' to SystemCommandHandlerKyrylo Silin2019-04-151-0/+34
|
* config: factor out exception_handler hook to a separate classexception-handler-refactoringKyrylo Silin2019-04-151-0/+64
|
* config: factor out color printer proc to ColorPrinterKyrylo Silin2019-04-141-0/+10
|
* config: factor out default hook definition to Pry::HooksKyrylo Silin2019-04-141-0/+28
|
* Move history file detection to Pry::HistoryKyrylo Silin2019-04-101-1/+27
| | | | | This makes `Pry::Config` a bit cleaner and history code is better off in `Pry::History`, since it's probably the most expected location.
* Move `default_editor_for_platform` to Pry::EditorKyrylo Silin2019-04-101-0/+42
| | | | | The name strongly suggests that this method belongs to `Pry::Editor` and it makes no sense to have it on `Pry` class.
* spec/command: refactor to cover more, and more clearlyKyrylo Silin2019-04-091-607/+486
|
* Test ClassCommandKyrylo Silin2019-04-081-0/+264
|
* Test BlockCommandKyrylo Silin2019-04-081-0/+63
|
* spec/command_set: delete unused ctxKyrylo Silin2019-04-061-8/+0
|
* command_set: refactor specsKyrylo Silin2019-04-041-515/+267
| | | | | | | In this change we: * Used modern RSpec API * Deleted unused methods
* helpers/command_helpers: add tests, refactor variable namesKyrylo Silin2019-03-302-27/+254
| | | | | | | | | | | | | | | | | First of all, we move the spec file from `spec` to `spec/helpers`. This is where it is supposed to be. Next, we add tests for all the methods that the module defines. During this process I had to change `module_function` to `extend self`. Rubocop doesn't like it for some unknown to me reason, so I had to disable the rule. There's no harm in doing so. Finally, I refactored some methods (low-hanging fruits only) and discovered that the `command_error` method is not necessary at all. All in all, this module is a lot better now but I feel like it shouldn't exist at all, since almost all methods are very specific to certain Pry commands. It's hardly a general purpose module for Pry plugins.
* color_printer_spec: add more specsKyrylo Silin2019-03-301-1/+56
| | | | Some code paths were not covered by unit tests.
* Stop requiring coderay in files that don't use itKyrylo Silin2019-03-282-4/+0
|
* Factor out all CodeRay code to Pry::SyntaxHighlighterKyrylo Silin2019-03-282-2/+2
| | | | | | | | This moves all the code related syntax highlighting and tokenization to a wrapper class of CodeRay. Benefits: * we reduce duplication (no need to call `scan(code, :ruby).term` everywhere) * swapping CodeRay becomes easier because it's isolated in one class
* rubocop: fix the Naming/ConstantName copKyrylo Silin2019-03-241-14/+14
|
* rubocop: fix the Naming/HeredocDelimiterCase copKyrylo Silin2019-03-241-4/+4
|
* rubocop: fix the Naming/UncommunicativeMethodParamName copKyrylo Silin2019-03-245-8/+8
|
* rubocop: fix Naming/HeredocDelimiterNaming copKyrylo Silin2019-03-247-24/+24
|
* rubocop: "fix" offences of the Security/Eval copKyrylo Silin2019-03-242-1/+3
|
* rubocop: fix offences of the Style/CaseEquality copKyrylo Silin2019-03-242-11/+3
|
* rubocop: fix offences of the Style/AccessModifierDeclarations copKyrylo Silin2019-03-232-7/+3
|