Sha256: dbb30dd8be1cf181996e81e81cf15df3fc3d6ff38709dff1ae56adb0d23b901d
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
require_relative '../test_helper' require 'hyperclient/entry_point' module Hyperclient describe EntryPoint do let(:api) do EntryPoint.new 'http://my.api.org' end before do stub_request(:get, "http://my.api.org/"). to_return(body: '{"_links": {"self": {"href": "http://my.api.org"}}}', headers: {content_type: 'application/json'}) end describe 'initialize' do it 'initializes a Resource at the entry point' do api.links['self'].url.must_equal 'http://my.api.org' end it 'setups the HTTP config' do options = {:headers => {'accept-encoding' => 'deflate, gzip'}} api = EntryPoint.new('http://my.api.org', options) api.config[:headers].must_include 'accept-encoding' end it 'sets the base_uri for HTTP' do api = EntryPoint.new('http://my.api.org') api.config[:base_uri].must_equal 'http://my.api.org' end end describe 'method missing' do it 'delegates undefined methods to the API when they exist' do Resource.any_instance.expects(:foo).returns 'foo' api.foo.must_equal 'foo' end it 'responds to missing methods' do Resource.any_instance.expects(:respond_to?).with('foo').returns(true) api.respond_to?(:foo).must_equal true end it 'raises an error when the method does not exist in the API' do lambda { api.this_method_does_not_exist }.must_raise(NoMethodError) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hyperclient-0.2.0 | test/hyperclient/entry_point_test.rb |
hyperclient-0.1.0 | test/hyperclient/entry_point_test.rb |