spec/bencodr/parser_spec.rb in bencodr-1.0.1 vs spec/bencodr/parser_spec.rb in bencodr-1.1.0

- old
+ new

@@ -171,6 +171,26 @@ it "should raise an error if there is a key with no value" do scanner = StringScanner.new("d1:ae") lambda{BEncodr::Parser.parse_dictionary(scanner)}.should raise_error BEncodr::BEncodeError end end +end + +describe String do + describe "#bdecode" do + it "should decode a bencoded string into a ruby string" do + "6:string".bdecode.should == "string" + end + + it "should decode a bencoded integer into a ruby integer" do + "i-1e".bdecode.should == -1 + end + + it "should decode a bencoded list into a ruby array" do + "le".bdecode.should == [] + end + + it "should decode a bencoded dictionary into a ruby hash" do + "de".bdecode.should == {} + end + end end \ No newline at end of file