spec/bencodr/io_spec.rb in bencodr-1.2.0 vs spec/bencodr/io_spec.rb in bencodr-2.0.0

- old
+ new

@@ -1,36 +1,34 @@ -require "spec" +require "spec_helper" describe File do + before :all do + @path = "tmp" + Dir.mkdir(@path) unless File.exists? @path + BEncodr.include! + end + + before :each do + @file = File.join(@path, 'test.bencodr') + @object = "string" + File.bencode(@file, @object) + end + describe "#bencode" do - context "when an object gets bencoded and written to a file" do - before :all do - @path = "tmp" - Dir.mkdir(@path) unless File.exists? @path - end + subject{ File } + + it{ File.should exist(@file) } + end + + describe "#bdecode" do + subject{ File } + it{ should bdecode(@file).to(@object) } + end + + after :each do + File.delete(@file) + end - before :each do - @file = File.join(@path, 'test.bencodr') - @object = "string" - File.bencode(@file, @object) - end - - it "should actually write a file" do - File.exists?(@file).should be_true - end - - describe "#bdecode" do - it "should properly encode the file" do - File.bdecode(@file).should == @object - end - end - - after :each do - File.delete(@file) - end - - after :all do - Dir.delete(@path) if File.exists? @path - end - end + after :all do + Dir.delete(@path) if File.exists? @path end end \ No newline at end of file