Skip to content

Commit

Permalink
Fix relative file loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkadiy Tetelman authored and arkadiyt committed May 17, 2018
1 parent 42d9213 commit 1f8bda1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/aws_public_ips/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class CLI
# AWS Neptune (still in preview / not GA yet)

def all_services
@all_services ||= Dir['lib/aws_public_ips/checks/*.rb'].map { |path| File.basename(path, '.rb') }.sort
@all_services ||= Dir["#{__dir__}/checks/*.rb"].map { |path| File.basename(path, '.rb') }.sort
end

def all_formats
@all_formats ||= Dir['lib/aws_public_ips/formatters/*.rb'].map { |path| File.basename(path, '.rb') }.sort
@all_formats ||= Dir["#{__dir__}/formatters/*.rb"].map { |path| File.basename(path, '.rb') }.sort
end

def parse(args)
Expand Down
7 changes: 7 additions & 0 deletions spec/aws_public_ips/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
expect { subject.parse(%w[--service blah]) }.to raise_error(ArgumentError, /Invalid service/)
end

it 'should select the right directory' do
Dir.chdir('/') do
options = subject.parse(%w[--service ec2 --format prettyjson])
expect(options).to include(services: %w[ec2], format: 'prettyjson')
end
end

it 'should run' do
expect(AwsPublicIps::Checks::Ec2).to receive(:run).and_return([{
id: 'i-0f22d0af796b3cf3a',
Expand Down

0 comments on commit 1f8bda1

Please sign in to comment.