Sha256: 400353f5725a050d0bd8dd29a6e9d32a135511efd95bbe692a2cfa79b9764471
Contents?: true
Size: 1.61 KB
Versions: 4
Compression:
Stored size: 1.61 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 'also works with entry points that are not in the root' do api.entry_point 'http://my.api.org/api' api.new.entry.url.must_equal 'http://my.api.org/api' 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hyperclient-0.0.7 | test/hyperclient_test.rb |
hyperclient-0.0.6 | test/hyperclient_test.rb |
hyperclient-0.0.5 | test/hyperclient_test.rb |
hyperclient-0.0.4 | test/hyperclient_test.rb |