Skip to content

Commit

Permalink
Cover parse_argv! method in Observed::System
Browse files Browse the repository at this point in the history
  • Loading branch information
KUOKA Yusuke committed Dec 5, 2013
1 parent 180d959 commit 4d27b63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/observed/application/oneshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_argv!(argv)

opts.parse!(command_line_args)

if command_line_args.size != 1
unless command_line_args.size == 1 || command_line_args.size == 2
fail InvalidArgumentError, "Invalid number of arguments #{command_line_args.size} where arguments are #{command_line_args}"
end

Expand Down
9 changes: 7 additions & 2 deletions spec/oneshot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def observe
end
end
end
context 'with configuration directories' do

describe '#parse_argv!' do
it 'parses ARGV like arrays and extracts Hash objects containing initialization parameters' do
argv = %w| -l logfile -d observed.rb foo1 |
params = Observed::Application::Oneshot.parse_argv! argv
expect(params).to eq({log_file: Pathname.new('logfile'), debug: true, config_file: 'observed.rb'})
expect(argv).to eq(%w| foo1 |)
end
end
end

0 comments on commit 4d27b63

Please sign in to comment.