Idiomatically mock OpenURI.open_uri with Minitest
I have code that invokes OpenURI.open_uri and I want to confirm the URI being used in the call (so a stub isn't going to work for me), but also intercept the call. I'm hoping not to have to abstract away the call to OpenURI.open_uri just for test purposes. What I've come up with seems verbose and overly complicated. under_test.rb require 'open-uri' class UnderTest def get_request(uri) open(uri).read end end test_under_test.rb require 'minitest/autorun' require './lib/under_test' class TestUnderTest < Mintest::Test def test_get_request @under_test = UnderTest.new mock_json = '{"json":[{"element