diff --git a/lib/eve_online.rb b/lib/eve_online.rb index 61f19c696..a0430c47a 100644 --- a/lib/eve_online.rb +++ b/lib/eve_online.rb @@ -73,5 +73,7 @@ require 'eve_online/sovereignty/campaigns' +require 'eve_online/eve_online' + module EveOnline end diff --git a/lib/eve_online/eve_online.rb b/lib/eve_online/eve_online.rb new file mode 100644 index 000000000..9cf19171a --- /dev/null +++ b/lib/eve_online/eve_online.rb @@ -0,0 +1,24 @@ +require 'memoist' + +module EveOnline + class EveOnline + extend Memoist + + attr_reader :key_id, :v_code + + def initialize(key_id, v_code) + @key_id = key_id + @v_code = v_code + end + + def account_status + Account::Status.new(key_id, v_code) + end + memoize :account_status + + def characters + Account::Characters.new(key_id, v_code).characters + end + memoize :characters + end +end diff --git a/spec/eve_online/eve_online_spec.rb b/spec/eve_online/eve_online_spec.rb new file mode 100644 index 000000000..0e2c14a91 --- /dev/null +++ b/spec/eve_online/eve_online_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe EveOnline::EveOnline do + specify { expect(described_class).to be_a(Memoist) } + + let(:key_id) { 123 } + + let(:v_code) { 'abc' } + + subject { described_class.new(key_id, v_code) } + + describe '#initialize' do + its(:key_id) { should eq(key_id) } + + its(:v_code) { should eq(v_code) } + end + + describe '#account_status' do + before do + # + # EveOnline::Account::Status.new(key_id, v_code) + # + expect(EveOnline::Account::Status).to receive(:new).with(key_id, v_code) + end + + specify { expect { subject.account_status }.not_to raise_error } + + specify { expect { subject.account_status }.to change { subject.instance_variable_defined?(:@_memoized_account_status) }.from(false).to(true) } + end + + describe '#characters' do + before do + # + # EveOnline::Account::Characters.new(key_id, v_code).characters + # + expect(EveOnline::Account::Characters).to receive(:new).with(key_id, v_code) do + double.tap do |a| + expect(a).to receive(:characters) + end + end + end + + specify { expect { subject.characters }.not_to raise_error } + + specify { expect { subject.characters }.to change { subject.instance_variable_defined?(:@_memoized_characters) }.from(false).to(true) } + end +end