mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
e5556a2be8
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).
66 lines
1.7 KiB
Ruby
66 lines
1.7 KiB
Ruby
# good idea ???
|
|
# if you're testing pry plugin you should require pry by yourself, no?
|
|
require 'pry' unless defined?(Pry)
|
|
|
|
class Pry
|
|
module Testable
|
|
require_relative "testable/pry_tester"
|
|
require_relative "testable/evalable"
|
|
require_relative "testable/mockable"
|
|
require_relative "testable/variables"
|
|
require_relative "testable/utility"
|
|
|
|
#
|
|
# When {Pry::Testable} is included into another module or class,
|
|
# the following modules are also included: {Pry::Testable::Mockable},
|
|
# {Pry::Testable::Evalable}, {Pry::Testable::Variables}, and
|
|
# {Pry::Testable::Utility}.
|
|
#
|
|
# @note
|
|
# Each of the included modules mentioned above may also be used
|
|
# standalone or in a pick-and-mix fashion.
|
|
#
|
|
# @param [Module] mod
|
|
# A class or module.
|
|
#
|
|
# @return [void]
|
|
#
|
|
def self.included(mod)
|
|
mod.module_eval do
|
|
include Pry::Testable::Mockable
|
|
include Pry::Testable::Evalable
|
|
include Pry::Testable::Variables
|
|
include Pry::Testable::Utility
|
|
end
|
|
end
|
|
|
|
#
|
|
# Sets various configuration options that make Pry optimal for a test
|
|
# environment, see source code for complete details.
|
|
#
|
|
# @return [void]
|
|
#
|
|
def self.set_testenv_variables
|
|
Pry.config = Pry::Config.new.merge(
|
|
color: false,
|
|
pager: false,
|
|
should_load_rc: false,
|
|
should_load_local_rc: false,
|
|
correct_indent: false,
|
|
collision_warning: false,
|
|
history_save: false,
|
|
history_load: false,
|
|
hooks: Pry::Hooks.new
|
|
)
|
|
end
|
|
|
|
#
|
|
# Reset the Pry configuration to their default values.
|
|
#
|
|
# @return [void]
|
|
#
|
|
def self.unset_testenv_variables
|
|
Pry.config = Pry::Config.new
|
|
end
|
|
end
|
|
end
|