add CommandSet#[]= spec.

This commit is contained in:
Robert Gleeson 2013-09-22 11:39:10 +02:00
parent 7441f44f2a
commit 4087a2ca32
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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