Skip to content

Commit

Permalink
address warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davetron5000 committed Jan 2, 2017
1 parent 962270b commit e1d7cbb
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 135 deletions.
1 change: 0 additions & 1 deletion lib/methadone/cli_logger.rb
Expand Up @@ -100,7 +100,6 @@ def initialize(log_device=$stdout,error_device=$stderr)

def level=(level)
super(level)
current_error_level = @stderr_logger.level
if (level > DEFAULT_ERROR_LEVEL) && @split_logs
@stderr_logger.level = level
end
Expand Down
2 changes: 1 addition & 1 deletion lib/methadone/cli_logging.rb
Expand Up @@ -48,7 +48,7 @@ def logger
def change_logger(new_logger)
raise ArgumentError,"Logger may not be nil" if new_logger.nil?
@@logger = new_logger
@@logger.level = @log_level if @log_level
@@logger.level = @log_level if defined?(@log_level) && @log_level
end

alias logger= change_logger
Expand Down
5 changes: 4 additions & 1 deletion lib/methadone/main.rb
Expand Up @@ -325,6 +325,8 @@ def setup_defaults
end

def add_defaults_to_docs
@env_var = nil unless defined? @env_var
@rc_file = nil unless defined? @rc_file
if @env_var && @rc_file
opts.separator ''
opts.separator 'Default values can be placed in:'
Expand All @@ -351,7 +353,7 @@ def set_defaults_from_env_var
end

def set_defaults_from_rc_file
if @rc_file && File.exists?(@rc_file)
if @rc_file && File.exist?(@rc_file)
File.open(@rc_file) do |file|
parsed = begin
YAML::load(file)
Expand Down Expand Up @@ -392,6 +394,7 @@ def normalize_defaults

# Handle calling main and trapping any exceptions thrown
def call_main
@leak_exceptions = nil unless defined? @leak_exceptions
@main_block.call(*ARGV)
rescue Methadone::Error => ex
raise ex if ENV['DEBUG']
Expand Down
8 changes: 4 additions & 4 deletions test/execution_strategy/test_jvm.rb
Expand Up @@ -53,9 +53,9 @@ class TestJVM < BaseTest
@results = @strategy.run_command(@command)
}
Then {
@results[0].should == @stdout
@results[1].should == @stderr
@results[2].exitstatus.should == @exitstatus
@results[0].should be == @stdout
@results[1].should be == @stderr
@results[2].exitstatus.should be == @exitstatus
}
end

Expand All @@ -65,7 +65,7 @@ class TestJVM < BaseTest
@klass = @strategy.exception_meaning_command_not_found
}
Then {
@klass.should == NativeException
@klass.should be == NativeException
}
end

Expand Down
10 changes: 5 additions & 5 deletions test/execution_strategy/test_open_3.rb
Expand Up @@ -23,8 +23,8 @@ class TestOpen_3 < BaseTest
@results = @strategy.run_command(@command)
}
Then {
@results[0].should == @stdout
@results[1].should == @stderr
@results[0].should be == @stdout
@results[1].should be == @stderr
@results[2].should be @status
}
end
Expand All @@ -46,8 +46,8 @@ class TestOpen_3 < BaseTest
@results = @strategy.run_command(@command)
}
Then {
@results[0].should == @stdout
@results[1].should == @stderr
@results[0].should be == @stdout
@results[1].should be == @stderr
@results[2].should be @status
}
end
Expand All @@ -58,7 +58,7 @@ class TestOpen_3 < BaseTest
@klass = @strategy.exception_meaning_command_not_found
}
Then {
@klass.should == Errno::ENOENT
@klass.should be == Errno::ENOENT
}
end

Expand Down
10 changes: 5 additions & 5 deletions test/execution_strategy/test_open_4.rb
Expand Up @@ -33,8 +33,8 @@ class TestOpen_4 < BaseTest
@results = @strategy.run_command(@command)
}
Then {
@results[0].should == @stdout
@results[1].should == @stderr
@results[0].should be == @stdout
@results[1].should be == @stderr
@results[2].should be @status
}
end
Expand Down Expand Up @@ -62,8 +62,8 @@ class TestOpen_4 < BaseTest
@results = @strategy.run_command(@command)
}
Then {
@results[0].should == @stdout
@results[1].should == @stderr
@results[0].should be == @stdout
@results[1].should be == @stderr
@results[2].should be @status
}
end
Expand All @@ -74,7 +74,7 @@ class TestOpen_4 < BaseTest
@klass = @strategy.exception_meaning_command_not_found
}
Then {
@klass.should == Errno::ENOENT
@klass.should be == Errno::ENOENT
}
end

Expand Down
34 changes: 17 additions & 17 deletions test/test_cli_logger.rb
Expand Up @@ -37,8 +37,8 @@ def tty?; true; end
When log_all_levels

Then {
$stdout.string.should == "debug\ninfo\n"
$stderr.string.should == "warn\nerror\nfatal\n"
$stdout.string.should be == "debug\ninfo\n"
$stderr.string.should be == "warn\nerror\nfatal\n"
}
end

Expand All @@ -58,8 +58,8 @@ def tty?; true; end
When log_all_levels

Then {
$stdout.string.should == ""
$stderr.string.should == "error\nfatal\n"
$stdout.string.should be == ""
$stderr.string.should be == "error\nfatal\n"
}
end

Expand All @@ -69,7 +69,7 @@ def tty?; true; end

Then stdout_should_have_everything
And {
$stderr.string.should == "warn\nerror\nfatal\n"
$stderr.string.should be == "warn\nerror\nfatal\n"
}
end

Expand All @@ -80,7 +80,7 @@ def tty?; true; end

Then stdout_should_have_everything
And {
$stderr.string.should == "fatal\n"
$stderr.string.should be == "fatal\n"
}
end

Expand All @@ -97,8 +97,8 @@ def tty?; true; end
When log_all_levels

Then {
@out.string.should == "debug\ninfo\nwarn\nerror\nfatal\n"
@err.string.should == "warn\nerror\nfatal\n"
@out.string.should be == "debug\ninfo\nwarn\nerror\nfatal\n"
@err.string.should be == "warn\nerror\nfatal\n"
}
end

Expand All @@ -108,8 +108,8 @@ def tty?; true; end
When log_all_levels

Then {
$stdout.string.should == "fatal\n"
$stderr.string.should == "warn\nerror\nfatal\n"
$stdout.string.should be == "fatal\n"
$stderr.string.should be == "warn\nerror\nfatal\n"
}
end

Expand All @@ -126,8 +126,8 @@ def tty?; true; end
}

Then {
$stdout.string.should match /the time.*DEBUG.*debug/
$stderr.string.should match /the time.*ERROR.*error/
$stdout.string.should match(/the time.*DEBUG.*debug/)
$stderr.string.should match(/the time.*ERROR.*error/)
}
end

Expand All @@ -137,8 +137,8 @@ def tty?; true; end
@logger << "foo"
}
Then {
$stdout.string.should == "foo"
$stderr.string.should == ""
$stdout.string.should be == "foo"
$stderr.string.should be == ""
}
end

Expand All @@ -154,8 +154,8 @@ def tty?; true; end
@logger.error("error")
}
Then {
$stdout.string.should == "debug\nerror\n"
$stderr.string.should == "ERROR_LOGGER: error\n"
$stdout.string.should be == "debug\nerror\n"
$stderr.string.should be == "ERROR_LOGGER: error\n"
}
end

Expand Down Expand Up @@ -211,7 +211,7 @@ def a_logger_with_blank_format(options = {})

def stdout_should_have_everything
proc do
$stdout.string.should == "debug\ninfo\nwarn\nerror\nfatal\n"
$stdout.string.should be == "debug\ninfo\nwarn\nerror\nfatal\n"
end
end

Expand Down
24 changes: 12 additions & 12 deletions test/test_cli_logging.rb
Expand Up @@ -32,8 +32,8 @@ def teardown
}

Then {
$stdout.string.should == "debug\ninfo\nwarn\nerror\nfatal\n"
$stderr.string.should == "warn\nerror\nfatal\n"
$stdout.string.should be == "debug\ninfo\nwarn\nerror\nfatal\n"
$stderr.string.should be == "warn\nerror\nfatal\n"
}
end

Expand All @@ -43,7 +43,7 @@ def teardown
@second = MyOtherClassThatLogsToStdout.new
}
Then {
@first.logger_id.should == @second.logger_id
@first.logger_id.should be == @second.logger_id
}
end

Expand All @@ -59,8 +59,8 @@ def teardown
end
}
Then {
@logger_id.should_not == @second.logger_id
@first.logger_id.should == @second.logger_id
@logger_id.should_not be == @second.logger_id
@first.logger_id.should be == @second.logger_id
}
end

Expand All @@ -76,8 +76,8 @@ def teardown
end
}
Then {
@logger_id.should_not == @second.logger_id
@first.logger_id.should == @second.logger_id
@logger_id.should_not be == @second.logger_id
@first.logger_id.should be == @second.logger_id
}
end

Expand All @@ -104,7 +104,7 @@ def teardown
@app.use_option(@level)
}
Then {
@app.logger.level.should == @level
@app.logger.level.should be == @level
}
end

Expand All @@ -120,7 +120,7 @@ def teardown
@app.change_logger(@other_logger)
}
Then {
@other_logger.level.should == @level
@other_logger.level.should be == @level
}
end

Expand All @@ -136,7 +136,7 @@ def teardown
send_signal_and_wait_a_moment('USR2')
}
Then {
@app.logger.level.should == Logger::DEBUG
@app.logger.level.should be == Logger::DEBUG
}
end

Expand All @@ -153,7 +153,7 @@ def teardown
@app.change_logger(@other_logger)
}
Then {
@other_logger.level.should == Logger::DEBUG
@other_logger.level.should be == Logger::DEBUG
}
end

Expand All @@ -169,7 +169,7 @@ def teardown
send_signal_and_wait_a_moment('USR2')
}
Then {
@app.logger.level.should == Logger::INFO
@app.logger.level.should be == Logger::INFO
}
end

Expand Down
8 changes: 4 additions & 4 deletions test/test_exit_now.rb
Expand Up @@ -16,8 +16,8 @@ class TestExitNow < BaseTest
}
Then {
exception = assert_raises(Methadone::Error,&@code)
exception.exit_code.should == @exit_code
exception.message.should == @message
exception.exit_code.should be == @exit_code
exception.message.should be == @message
}
end

Expand All @@ -30,8 +30,8 @@ class TestExitNow < BaseTest
}
Then {
exception = assert_raises(Methadone::Error,&@code)
exception.exit_code.should == 1
exception.message.should == @message
exception.exit_code.should be == 1
exception.message.should be == @message
}
end
end

0 comments on commit e1d7cbb

Please sign in to comment.