Sha256: 3090a043b5c78e6c70bee8021aa83f60439b4f8c0a8adbd6cf99f96c886de9d7
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
# encoding: UTF-8 require "spec" require "spec_helper" describe String do describe "#bencode" do it "should encode a string" do "string".bencode.should == "6:string" end it "should encode a zero length string" do "".bencode.should == "0:" end end end describe Symbol do describe "#bencode" do it "should encode a symbol" do :symbol.bencode.should == "6:symbol" end end end describe URI::Generic do describe "#bencode" do it "should encode a http uri" do uri = URI.parse("http://github.com/blatyo/bencode") uri.bencode.should == "32:http://github.com/blatyo/bencode" end it "should encode a https uri" do uri = URI.parse("https://github.com/blatyo/bencode") uri.bencode.should == "33:https://github.com/blatyo/bencode" end it "should encode a ftp uri" do uri = URI.parse("ftp://github.com/blatyo/bencode") uri.bencode.should == "31:ftp://github.com/blatyo/bencode" end it "should encode a ldap uri" do uri = URI.parse("ldap://github.com/blatyo/bencode") uri.bencode.should == "32:ldap://github.com/blatyo/bencode" end it "should encode a mailto uri" do uri = URI.parse("mailto:sudo@sudoers.su") uri.bencode.should == "22:mailto:sudo@sudoers.su" end end end describe BEncode::String do describe "#register" do context "once an object has been registered as a BEncode string" do before :all do BEncode::String.register Range end context "an instance of that object" do it "should respond to bencode" do (1..2).should respond_to :bencode end it "should encode to a bencoded string" do (1..2).bencode.should == "4:1..2" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bencode_blatyo-1.0.1 | spec/bencode/string_spec.rb |
bencode_blatyo-1.0.0 | spec/bencode/string_spec.rb |