From d0eef2dbe9d1178111cd768116a66b32a3a4b2b5 Mon Sep 17 00:00:00 2001 From: pseudomuto Date: Wed, 18 Dec 2013 19:12:43 -0500 Subject: moving cli to lib and updating bin file --- test/downloader_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/downloader_test.rb (limited to 'test/downloader_test.rb') diff --git a/test/downloader_test.rb b/test/downloader_test.rb new file mode 100644 index 0000000..930ad56 --- /dev/null +++ b/test/downloader_test.rb @@ -0,0 +1,26 @@ +require 'test_helper' + +class DownloaderTest < Minitest::Test + + def test_get_json_requests_and_parses_content + endpoint = 'http://somehost.com/file.json' + response = '{ "name": "value" }' + FakeWeb.register_uri(:get, endpoint, body: response) + JSON.stubs(:parse).with(response).once + + Dashing::Downloader.get_json(endpoint) + end + + def test_get_json_raises_on_bad_request + FakeWeb.register_uri(:get, 'http://dead-host.com/', status: '404') + + assert_raises(OpenURI::HTTPError) do + Dashing::Downloader.get_json('http://dead-host.com/') + end + end + + def test_load_gist_attempts_to_get_the_gist + Dashing::Downloader.stubs(:get_json).once + Dashing::Downloader.get_gist(123) + end +end -- cgit v1.2.3