spec/tcr_spec.rb in tcr-0.0.3 vs spec/tcr_spec.rb in tcr-0.0.4

- old
+ new

@@ -16,11 +16,11 @@ it "has an empty list of hook ports by default" do TCR.configuration.hook_tcp_ports.should == [] end end - describe ".confige" do + describe ".configure" do it "configures cassette location" do expect { TCR.configure { |c| c.cassette_library_dir = "some/dir" } }.to change{ TCR.configuration.cassette_library_dir }.from("fixtures/tcr_cassettes").to("some/dir") end @@ -36,9 +36,32 @@ TCR.configure { |c| c.hook_tcp_ports = [25] } expect { tcp_socket = TCPSocket.open("aspmx.l.google.com", 25) }.to raise_error(TCR::NoCassetteError) end + + describe ".turned_off" do + it "requires a block to call" do + expect { + TCR.turned_off + }.to raise_error(ArgumentError) + end + + it "disables hooks within the block" do + TCR.configure { |c| c.hook_tcp_ports = [25] } + TCR.turned_off do + TCR.configuration.hook_tcp_ports.should == [] + end + end + + it "makes real TCPSocket.open calls even when hooks are setup" do + TCR.configure { |c| c.hook_tcp_ports = [25] } + expect(TCPSocket).to receive(:real_open) + TCR.turned_off do + tcp_socket = TCPSocket.open("aspmx.l.google.com", 25) + end + end + end describe ".use_cassette" do before(:each) { TCR.configure { |c| c.hook_tcp_ports = [25] \ No newline at end of file