Skip to content

Commit

Permalink
the object 'options' provided by Commander doesn't have methods to te… (
Browse files Browse the repository at this point in the history
#137)

* the object 'options' provided by Commander doesn't have methods to test responses

* upating tests

* upating tests

* removing white space

* remove whitespace
  • Loading branch information
sepulworld committed Jul 24, 2016
1 parent 560a8ab commit cfac194
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 6 additions & 9 deletions lib/aptly_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@ class AptlyCommand
include HTTMultiParty

attr_accessor :config

def initialize(config, options = nil)
@config = config
options ||= Options.new

if options.respond_to?(:server) && options.server
if options.server
@config[:server] = options.server
end

if options.respond_to?(:port) && options.port
if options.port
@config[:port] = options.port
end

if options.respond_to?(:username) && options.username
if options.username
@config[:username] = options.username
end

if options.respond_to?(:password) && options.password
if options.password
@config[:password] = options.password
end

if options.respond_to?(:debug) && options.debug
if options.debug
@config[:debug] = options.debug
end

Expand Down Expand Up @@ -63,9 +62,7 @@ def initialize(config, options = nil)
end
end

if respond_to?(:debug_output)
debug_output $stdout if @config[:debug] == true
end
self.class.debug_output $stdout if @config[:debug] == true
end
end
end
6 changes: 4 additions & 2 deletions test/test_aptly_command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


require 'minitest_helper.rb'
require 'minitest/autorun'

Expand Down Expand Up @@ -39,14 +41,14 @@ def password(_prompt)
options.port = 9000
options.username = 'me'
options.password = 'secret'
options.debug = true
options.debug = false
config = AptlyCli::AptlyLoad.new.configure_with(nil)
cmd = AptlyCli::AptlyCommand.new(config, options)
cmd.config[:server].must_equal 'my-server'
cmd.config[:port].must_equal 9000
cmd.config[:username].must_equal 'me'
cmd.config[:password].must_equal 'secret'
cmd.config[:debug].must_equal true
cmd.config[:debug].must_equal nil
end

it 'can process an option with \'${PROMPT}\' in it' do
Expand Down

0 comments on commit cfac194

Please sign in to comment.