spec/tcr_spec.rb in tcr-0.1.1 vs spec/tcr_spec.rb in tcr-0.1.2

- old
+ new

@@ -13,12 +13,14 @@ TCR.configuration.reset_defaults! end around(:each) do |example| File.unlink("test.json") if File.exists?("test.json") + File.unlink("test.yaml") if File.exists?("test.yaml") example.run File.unlink("test.json") if File.exists?("test.json") + File.unlink("test.yaml") if File.exists?("test.yaml") end describe ".configuration" do it "has a default cassette location configured" do TCR.configuration.cassette_library_dir.should == "fixtures/tcr_cassettes" @@ -155,17 +157,41 @@ tcp_socket = TCPSocket.open("smtp.mandrillapp.com", 2525) end }.to change{ File.exists?("./test.json") }.from(false).to(true) end + it "creates a cassette file on use with yaml" do + TCR.configure { |c| c.format = "yaml" } + + expect { + TCR.use_cassette("test") do + tcp_socket = TCPSocket.open("smtp.mandrillapp.com", 2525) + end + }.to change{ File.exists?("./test.yaml") }.from(false).to(true) + end + it "records the tcp session data into the file" do TCR.use_cassette("test") do tcp_socket = TCPSocket.open("smtp.mandrillapp.com", 2525) io = Net::InternetMessageIO.new(tcp_socket) line = io.readline tcp_socket.close end cassette_contents = File.open("test.json") { |f| f.read } + cassette_contents.include?("220 smtp.mandrillapp.com ESMTP").should == true + end + + it "records the tcp session data into the yaml file" do + TCR.configure { |c| c.format = "yaml" } + + TCR.use_cassette("test") do + tcp_socket = TCPSocket.open("smtp.mandrillapp.com", 2525) + io = Net::InternetMessageIO.new(tcp_socket) + line = io.readline + tcp_socket.close + end + cassette_contents = File.open("test.yaml") { |f| f.read } + cassette_contents.include?("---").should == true cassette_contents.include?("220 smtp.mandrillapp.com ESMTP").should == true end it "plays back tcp sessions without opening a real connection" do expect(TCPSocket).to_not receive(:real_open)