Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the requirement to authenticate before calling a service object #112

merged 1 commit into from Sep 5, 2014
Changes from all commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.


Just for now

@@ -21,9 +21,17 @@ def initialize

class SessionDataNotProvidedError < StandardError
def initialize
super "default_session_data is not initialized and no session data was "\
"provided in the method call."
def initialize(service_name, request_name)
super "\n\nERROR: default_session_data is not initialized and no session data was provided in\n"\
"the method call. You have two ways to fix this:\n\n"\
" 1) Call Session#authenticate before calling Session##{service_name}_service, or\n\n"\
" 2) If you're really sure you don't want to authenticate beforehand,\n"\
" construct the method call this way:\n\n"\
" service = session.#{service_name}_service\n"\
" service.request :#{request_name}, :api_version => :v2, :session_data => sessiondatavar\n\n"\
" Replace :v2 with whatever available version you want to use and make sure sessiondatavar\n"\
" is a hash that contains, at least, the :base_url key. Other keys, such as :service_token may\n"\
" be needed depending on what the request class you are calling requires.\n\n"

@@ -75,7 +83,7 @@ def request(request_name, options={}, &params)

session_data = options[:session_data] || default_session_data

raise unless session_data
raise, request_name) unless session_data

[:base_url].each do |k|
session_data[k] = options[k] if options[k]
@@ -152,8 +152,6 @@ def environment

def get_service_obj(service_name)
raise unless self.authenticated?

@services ||= {}

if @services[service_name].nil?
@@ -261,20 +261,19 @@ def new_session

describe '#xxx_service' do

it 'raises a NotAuthenticatedError if called without authenticating first' do
the_method = lambda { new_session.identity_service }

the_method.must_raise Aviator::Session::NotAuthenticatedError

it 'returns an instance of the indicated service' do
session = new_session


it 'returns an instance of the indicated service even if not authenticated' do
session = new_session
session.authenticated?.must_equal false


end # describe 'aviator/core/service'
ProTip! Use n and p to navigate between commits in a pull request.