Commit 0a9d7bf1 authored by sergio1990's avatar sergio1990

Requesting ssoid if needed

Requesting ssoid in initialisation process causes many problem
particularly when testing in objective app
parent 52272373
......@@ -3,12 +3,6 @@ require "betfair_api_ng_rails/errors"
module BetfairApiNgRails
module Api
class Connection
attr_reader :ssoid
def initialize
request_ssoid
end
def request(method, params = {})
provider.fetch method: method, params: hashing(params)
......@@ -22,11 +16,11 @@ module BetfairApiNgRails
protected
def provider
@_provider ||= BetfairApiNgRails::Api::Provider.new ssoid
@_provider ||= BetfairApiNgRails::Api::Provider.new request_ssoid
end
def request_ssoid
@ssoid = BetfairApiNgRails::Api::SessionManager.new_ssoid
@_ssoid ||= BetfairApiNgRails::Api::SessionManager.new_ssoid
end
def hashing(params)
......
......@@ -4,15 +4,6 @@ describe BetfairApiNgRails::Api::Connection do
subject { described_class.new }
describe "#initialize" do
it "requests session identifier" do
expect_any_instance_of(described_class).to receive(:request_ssoid)
described_class.new
end
end
describe "#request" do
let(:provider) { double(:provider) }
......@@ -21,7 +12,6 @@ describe BetfairApiNgRails::Api::Connection do
let(:logger) { double(:logger) }
before(:each) do
expect_any_instance_of(described_class).to receive(:request_ssoid)
expect(subject).to receive(:init_parser).and_return parser
BetfairApiNgRails.log = logger
allow(logger).to receive(:write)
......@@ -41,10 +31,11 @@ describe BetfairApiNgRails::Api::Connection do
describe "#provider" do
before(:each) { expect_any_instance_of(described_class).to receive(:request_ssoid) }
let(:ssoid) { double(:ssoid) }
it "inits new provider" do
expect(BetfairApiNgRails::Api::Provider).to receive(:new)
expect(BetfairApiNgRails::Api::Provider).to receive(:new).with ssoid
expect(subject).to receive(:request_ssoid).and_return ssoid
subject.send(:provider)
end
......@@ -64,8 +55,6 @@ describe BetfairApiNgRails::Api::Connection do
let(:hashalator) { double(:hashalator) }
let(:params) { double(:params) }
before(:each) { expect_any_instance_of(described_class).to receive(:request_ssoid) }
it "hashalators params" do
expect(BetfairApiNgRails::Api::Hashalator).to receive(:new).with(params).and_return hashalator
expect(hashalator).to receive(:to_hash)
......
......@@ -9,7 +9,7 @@ describe BetfairApiNgRails::Api::Logs::ConsoleLogger do
let(:string) { "some content" }
it "puts content to console" do
expect(object).to receive(:puts).with string
expect(object).to receive(:puts).with "\e[0;32;49msome content\e[0m"
object.write string
end
......
......@@ -14,7 +14,7 @@ describe BetfairApiNgRails::Api::Logs::FileLogger do
it "writes passed string to log file" do
expect(File).to receive(:open).and_yield file
expect(file).to receive(:write).with(string)
expect(file).to receive(:puts).with(string)
object.write string
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