Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/active_resource/http_mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ def http_stub
end

def unstub_http?
HttpMock.net_connection_enabled? && defined?(@http) && @http.kind_of?(HttpMock)
HttpMock.net_connection_enabled? && (!defined?(@http) || @http.kind_of?(HttpMock))
end

def stub_http?
HttpMock.net_connection_disabled? && defined?(@http) && @http.kind_of?(Net::HTTP)
HttpMock.net_connection_disabled? && (!defined?(@http) || @http.kind_of?(Net::HTTP))
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/cases/connection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ def test_enable_net_connection
end
end

def test_enable_net_connection_first_time
keep_net_connection_status do
ActiveResource::HttpMock.enable_net_connection!
assert @conn.send(:http).kind_of?(Net::HTTP)
end
end

def test_disable_net_connection
keep_net_connection_status do
ActiveResource::HttpMock.enable_net_connection!
Expand Down
Loading