1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

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) if command.equal?(nil)
return commands.delete(pattern) return commands.delete(pattern)
end end
unless command < Pry::Command unless Class === command && command < Pry::Command
raise TypeError, "command is not a subclass of Pry::Command" raise TypeError, "command is not a subclass of Pry::Command"
end end
bind_command_to_pattern = pattern != command.match 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"] = @set["help"]
@set["help-1"].match.should == "help-1" @set["help-1"].match.should == "help-1"
end end
it "raises a TypeError when command is not a subclass of Pry::Command" do
lambda { @set["help"] = "hello" }.should.raise TypeError
end
end end
it 'should call the block used for the command when it is called' do it 'should call the block used for the command when it is called' do