pry-command-set-registry 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bc4e47b4fe6de4fd01ea656dc1b5b30f901c2c8
|
4
|
+
data.tar.gz: d117d60905175b6b40a17e7ae02b71fbd7d9d12b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85515d27354c4246fda7a4b148678dd9abf0f4c4a3d91871fb5fd27fd65d31f7ecab11fbd17adea09c662bad36470cfc4a650ad47c182b8e9b55aaaaaf6938c7
|
7
|
+
data.tar.gz: 984954420617368b4fad4f497573ccebdd9862756163754e1728f6f2baa309f4e485554561274885770ba341478b5f6dc1531ca9a644e4692bea1dad4f5764cb
|
@@ -9,6 +9,10 @@ module PryCommandSetRegistry
|
|
9
9
|
|
10
10
|
begin
|
11
11
|
set = target.eval(command_set_name)
|
12
|
+
unless set.respond_to?(:commands) && set.commands.is_a?(Hash)
|
13
|
+
registered_set = PryCommandSetRegistry.command_set(command_set_name)
|
14
|
+
set = registered_set if registered_set
|
15
|
+
end
|
12
16
|
rescue NameError
|
13
17
|
set = PryCommandSetRegistry.command_set(command_set_name)
|
14
18
|
::Kernel.raise if set.nil?
|
data/test/unit/commands_test.rb
CHANGED
@@ -49,6 +49,25 @@ class CommandsTest < PryCommandSetRegistry::TestCase
|
|
49
49
|
assert_equal true, context_command_called
|
50
50
|
assert_equal false, registry_command_called
|
51
51
|
end
|
52
|
+
|
53
|
+
should "fallback to registry if eval result doesn't seem to be a command set" do
|
54
|
+
registry_command_called = false
|
55
|
+
PryCommandSetRegistry.define_command_set("TestCommand", "test") do
|
56
|
+
command("test", "test") do
|
57
|
+
registry_command_called = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
some_const = Object.new
|
62
|
+
# This will return false anyway, but make sure it gets called to ensure
|
63
|
+
# the eval is resolving to the expected object before falling back.
|
64
|
+
some_const.expects(:respond_to?).with(:commands).returns(false)
|
65
|
+
Object::TestCommand = some_const
|
66
|
+
context = Pry.binding_for(Object.new)
|
67
|
+
run_command("import-set TestCommand", :context => context)
|
68
|
+
run_command("test")
|
69
|
+
assert_equal true, registry_command_called
|
70
|
+
end
|
52
71
|
end
|
53
72
|
|
54
73
|
context "list-sets" do
|