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

- old
+ new

@@ -139,10 +139,18 @@ expect(TCR.cassette).to be_nil TCR.use_cassette("test") { } expect(TCR.cassette).to be_nil end + it "resets the cassette after an error" do + expect(TCR.cassette).to be_nil + expect { + TCR.use_cassette("test") { raise "Whoops!" } + }.to raise_error("Whoops!") + expect(TCR.cassette).to be_nil + end + it "creates a cassette file on use" do expect { TCR.use_cassette("test") do tcp_socket = TCPSocket.open("smtp.mandrillapp.com", 2525) end @@ -296,8 +304,20 @@ smtp = Net::SMTP.start("mail.smtp2go.com", 2525) smtp = Net::SMTP.start("mail.smtp2go.com", 2525) end }.to raise_error(TCR::NoMoreSessionsError) end + end + end + + it "replaces sockets created with Socket.tcp" do + TCR.configure { |c| + c.hook_tcp_ports = [23] + c.cassette_library_dir = "." + } + + TCR.use_cassette("test") do + sock = Socket.tcp("towel.blinkenlights.nl", 23, {}) + expect(sock).to be_a(TCR::RecordableTCPSocket) end end end