Skip to content

Commit

Permalink
Replace Kernel.warn with $stderr.puts
Browse files Browse the repository at this point in the history
My project's rake task doesn't show warnings so just print directly to
stderr
  • Loading branch information
sandro committed Apr 26, 2010
1 parent 75eb75a commit fe41e24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/specjour/rsync_daemon.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def command
def check_config_version def check_config_version
File.read(config_file) =~ /\A# (\d+.\d+.\d+)/ File.read(config_file) =~ /\A# (\d+.\d+.\d+)/
if out_of_date? Regexp.last_match(1) if out_of_date? Regexp.last_match(1)
Kernel.warn <<-WARN $stderr.puts <<-WARN
Specjour has made changes to the way #{CONFIG_FILE_NAME} is generated. Specjour has made changes to the way #{CONFIG_FILE_NAME} is generated.
Back up '#{config_file}' Back up '#{config_file}'
and re-run the dispatcher to generate the new config file. and re-run the dispatcher to generate the new config file.
WARN WARN
end end
end end
Expand Down
4 changes: 2 additions & 2 deletions spec/rsync_daemon_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
describe "#check_config_version" do describe "#check_config_version" do
it "warns when the version is out of date" do it "warns when the version is out of date" do
stub(File).read { "# 0.0.0\n" } stub(File).read { "# 0.0.0\n" }
mock(Kernel).warn(/made changes/) mock($stderr).puts(/made changes/)
subject.send(:check_config_version) subject.send(:check_config_version)
end end


it "doesn't warn when the version isn't out of date" do it "doesn't warn when the version isn't out of date" do
stub(File).read { "# #{Specjour::RsyncDaemon::CONFIG_VERSION}\n" } stub(File).read { "# #{Specjour::RsyncDaemon::CONFIG_VERSION}\n" }
dont_allow(Kernel).warn dont_allow($stderr).puts
subject.send(:check_config_version) subject.send(:check_config_version)
end end
end end
Expand Down

0 comments on commit fe41e24

Please sign in to comment.