test/test_json.rb in sibit-0.17.0 vs test/test_json.rb in sibit-0.18.0

- old
+ new

@@ -19,19 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'minitest/autorun' +require 'webmock/minitest' require 'uri' require_relative '../lib/sibit/json' # Sibit::Json test. # Author:: Yegor Bugayenko (yegor256@gmail.com) # Copyright:: Copyright (c) 2019-2020 Yegor Bugayenko # License:: MIT class TestJson < Minitest::Test def test_loads_hash - WebMock.allow_net_connect! - json = Sibit::Json.new.get(URI('https://api-r.bitcoinchain.com/v1/status')) - assert(!json['hash'].nil?) + stub_request(:get, 'https://hello.com').to_return(body: '{"test":123}') + json = Sibit::Json.new.get(URI('https://hello.com')) + assert_equal(123, json['test']) + json = Sibit::Json.new.get(URI('https://hello.com/')) + assert_equal(123, json['test']) end end