Sha256: 77742fcf0f56287149d0b2a2801233159a3063ee3e7081dd55ac9bb8c8992988
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require_relative 'test_helper' require 'hyperclient' describe Hyperclient do let(:api) do Class.new do include Hyperclient end end describe 'entry point' do it 'sets the entry point for Hyperclient::Resource' do api.entry_point 'http://my.api.org' Hyperclient::Resource.new('/').url.must_include 'http://my.api.org' end end describe 'entry' do before do api.entry_point 'http://my.api.org' end it 'initializes a Resource at the entry point' do api.new.entry.url.must_equal 'http://my.api.org/' end it 'sets the Resource name' do api.new.name.must_equal 'Entry point' end end describe 'auth' do it 'sets authentication type' do api.auth(:digest, nil, nil) api.http_options[:http][:auth][:type].must_equal :digest end it 'sets the authentication credentials' do api.auth(:digest, 'user', 'secret') api.http_options[:http][:auth][:credentials].must_include 'user' api.http_options[:http][:auth][:credentials].must_include 'secret' end end describe 'method missing' do class Hyperclient::Resource def foo 'foo' end end it 'delegates undefined methods to the API when they exist' do api.new.foo.must_equal 'foo' end it 'raises an error when the method does not exist in the API' do lambda { api.new.this_method_does_not_exist }.must_raise(NoMethodError) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hyperclient-0.0.3 | test/hyperclient_test.rb |
hyperclient-0.0.2 | test/hyperclient_test.rb |