spec/bencode_spec.rb in bencode_blatyo-1.0.0 vs spec/bencode_spec.rb in bencode_blatyo-1.0.1
- old
+ new
@@ -41,12 +41,17 @@
end
end
describe "#encode_file" do
context "when an object gets bencoded and written to a file" do
+ before :all do
+ @path = File.join(File.dirname(__FILE__), '..', 'tmp')
+ Dir.mkdir(@path) unless File.exists? @path
+ end
+
before :each do
- @file = File.join(File.dirname(__FILE__), '..', 'tmp', 'test.bencode')
+ @file = File.join(@path, 'test.bencode')
@object = "string"
BEncode.encode_file(@file, @object)
end
it "should actually write a file" do
@@ -58,9 +63,18 @@
end
after :each do
File.delete(@file)
end
+
+ after :all do
+ Dir.delete(@path) if File.exists? @path
+ end
+ end
+
+ it "should read a torrent with newlines as part of a string without raising an error" do
+ file = File.join(File.dirname(__FILE__), 'samples', 'python.torrent')
+ lambda{BEncode.decode_file file}.should_not raise_error
end
end
context "when parsing and then encoding" do
it "should be equal to the pre-parsed and encoded bencoded string" do
\ No newline at end of file