Commit d2d42bae authored by Sergey Gernyak's avatar Sergey Gernyak

Fetching account in connection

parent 86c006f4
......@@ -37,6 +37,12 @@ module BetfairApiNgRails
def hashing(params)
BetfairApiNgRails::Api::Hashalator.new(params).to_hash
end
def account
acc = BetfairApiNgRails.account_manager.get account_name
throw BetfairApiNgRails::NoAccountProvided unless acc
acc
end
end
end
end
......@@ -8,4 +8,7 @@ module BetfairApiNgRails
@info = info
end
end
class NoAccountProvided < ::StandardError
end
end
......@@ -60,5 +60,22 @@ describe BetfairApiNgRails::Api::Connection do
subject.send :hashing, params
end
end
describe '#account' do
context 'when it is found' do
it 'returns this one' do
expect(BetfairApiNgRails).to receive_message_chain(:account_manager, :get).and_return double
connection.send :account
end
end
context 'when it is not found' do
it 'raises error' do
expect{
connection.send :account
}.to raise_exception
end
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment