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

Add basic single point #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/eve_online.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@

require 'eve_online/sovereignty/campaigns'

require 'eve_online/eve_online'

module EveOnline
end
24 changes: 24 additions & 0 deletions lib/eve_online/eve_online.rb
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions spec/eve_online/eve_online_spec.rb
Original file line number Diff line number Diff line change
@@ -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