diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 19a3fa7f..b1d1e199 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -339,7 +339,7 @@ class Pry if command.equal?(nil) return commands.delete(pattern) end - unless command < Pry::Command + unless Class === command && command < Pry::Command raise TypeError, "command is not a subclass of Pry::Command" end bind_command_to_pattern = pattern != command.match diff --git a/spec/command_set_spec.rb b/spec/command_set_spec.rb index 3dcc2f47..5e45724b 100644 --- a/spec/command_set_spec.rb +++ b/spec/command_set_spec.rb @@ -30,6 +30,10 @@ describe Pry::CommandSet do @set["help-1"] = @set["help"] @set["help-1"].match.should == "help-1" end + + it "raises a TypeError when command is not a subclass of Pry::Command" do + lambda { @set["help"] = "hello" }.should.raise TypeError + end end it 'should call the block used for the command when it is called' do