diff options
author | azul <azul@riseup.net> | 2016-07-12 10:39:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-12 10:39:58 +0200 |
commit | d7599715c6d24534dcccbe29cfc058e534039053 (patch) | |
tree | 14824b08c4d0889e9767171ac5bafe3316a607f9 /test/unit/adapters | |
parent | 27196b87e8d0ce5325381ea96ccd68ced8ee2e4d (diff) | |
parent | 6732fef4df156a02ed83f006f19f66cf567b5340 (diff) |
Merge pull request #5 from azul/celluloid
Use Celluloid, Reel and Celluloid I/O based http requests
Diffstat (limited to 'test/unit/adapters')
-rw-r--r-- | test/unit/adapters/celluloid_http_test.rb | 39 | ||||
-rw-r--r-- | test/unit/adapters/em_http_test.rb | 25 |
2 files changed, 39 insertions, 25 deletions
diff --git a/test/unit/adapters/celluloid_http_test.rb b/test/unit/adapters/celluloid_http_test.rb new file mode 100644 index 0000000..4381b8f --- /dev/null +++ b/test/unit/adapters/celluloid_http_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' +require 'nickserver/adapters/celluloid_http' + +class Nickserver::Adapters::CelluloidHttpTest < Minitest::Test + + def setup + super + Celluloid.boot + end + + def teardown + Celluloid.shutdown + super + end + + def test_successful_request + url = 'http://url.to' + stub_http_request(:get, url) + .with(query: {key: :value}) + .to_return status: 200, body: 'body' + status, body = adapter.get(url, query: {key: :value}) + assert_equal 200, status + assert_equal 'body', body + end + + def test_https_for_hkp + url = Nickserver::Config.hkp_url + real_network do + status, _body = adapter.get url + assert_equal 404, status + end + end + + protected + + def adapter + @adapter ||= Nickserver::Adapters::CelluloidHttp.new + end +end diff --git a/test/unit/adapters/em_http_test.rb b/test/unit/adapters/em_http_test.rb deleted file mode 100644 index 659ff1b..0000000 --- a/test/unit/adapters/em_http_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'test_helper' -require 'nickserver/adapters/em_http' - -class Nickserver::Adapters::EmHttpTest < Minitest::Test - - def test_successful_request - url = 'http://url.to' - stub_http_request(:get, url) - .with(query: {key: :value}) - .to_return status: 200, body: 'body' - EM.run do - adapter.get(url, query: {key: :value}) do |status, body| - assert_equal 200, status - assert_equal 'body', body - EM.stop - end - end - end - - protected - - def adapter - Nickserver::Adapters::EmHttp.new - end -end |