From ece0b9bf87e7fd7b3d8d59352934dd07f9183df3 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Thu, 16 Jan 2014 03:29:52 +0000 Subject: [PATCH] * suppressing puts to stdout in test runs --- .../models/icecast_admin_authentication.rb | 2 +- .../jam_ruby/models/icecast_directory_spec.rb | 20 ++++++++++++++++--- .../models/icecast_listen_socket_spec.rb | 8 +++++++- .../jam_ruby/models/icecast_logging_spec.rb | 15 +++++++++----- .../spec/jam_ruby/models/icecast_path_spec.rb | 20 ++++++++++++++----- .../jam_ruby/models/icecast_security_spec.rb | 15 +++++++++++--- .../icecast_user_authentication_spec.rb | 5 +++-- 7 files changed, 65 insertions(+), 20 deletions(-) diff --git a/ruby/lib/jam_ruby/models/icecast_admin_authentication.rb b/ruby/lib/jam_ruby/models/icecast_admin_authentication.rb index f4ce4a1df..0e1a57808 100644 --- a/ruby/lib/jam_ruby/models/icecast_admin_authentication.rb +++ b/ruby/lib/jam_ruby/models/icecast_admin_authentication.rb @@ -44,7 +44,7 @@ module JAmXml end end unless ident <= 0 - puts "#{tbse}" + output.puts "#{tbse}" end end diff --git a/ruby/spec/jam_ruby/models/icecast_directory_spec.rb b/ruby/spec/jam_ruby/models/icecast_directory_spec.rb index 96c44d515..7e22db9a2 100644 --- a/ruby/spec/jam_ruby/models/icecast_directory_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_directory_spec.rb @@ -1,17 +1,31 @@ require 'spec_helper' +require 'stringio' +=begin +example output: + + + 15 + http://dir.xiph.org/cgi-bin/yp-cgi + +=end describe IcecastDirectory do let(:idir) { IcecastDirectory.new } + let(:output) { StringIO.new } - before(:all) do + before(:each) do end - it "save" do idir.save.should be_true - idir.dumpXml + idir.dumpXml(1, output) + + output.rewind + directory = Nokogiri::XML(output) + directory.css('directory yp-url-timeout').text.should == "15" + directory.css('directory yp-url').text.should == "http://dir.xiph.org/cgi-bin/yp-cgi" end end diff --git a/ruby/spec/jam_ruby/models/icecast_listen_socket_spec.rb b/ruby/spec/jam_ruby/models/icecast_listen_socket_spec.rb index 61f773ea9..59aec8cd1 100644 --- a/ruby/spec/jam_ruby/models/icecast_listen_socket_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_listen_socket_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe IcecastListenSocket do let(:iobj) { IcecastListenSocket.new } + let(:output) { StringIO.new } before(:all) do @@ -10,7 +11,12 @@ describe IcecastListenSocket do it "save" do iobj.save.should be_true - iobj.dumpXml + iobj.dumpXml(1, output) + + output.rewind + directory = Nokogiri::XML(output) + directory.css('listen-socket port').text.should == "8001" + directory.css('listen-socket shoutcast-compat').text.should == "0" end end diff --git a/ruby/spec/jam_ruby/models/icecast_logging_spec.rb b/ruby/spec/jam_ruby/models/icecast_logging_spec.rb index 5e094ba30..7ecc860e6 100644 --- a/ruby/spec/jam_ruby/models/icecast_logging_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_logging_spec.rb @@ -3,14 +3,19 @@ require 'spec_helper' describe IcecastLogging do let(:iobj) { IcecastLogging.new } - - before(:all) do - - end + let(:output) { StringIO.new } it "save" do iobj.save.should be_true - iobj.dumpXml + iobj.dumpXml(1, output) + + output.rewind + directory = Nokogiri::XML(output) + directory.css('logging accesslog').text.should == "access.log" + directory.css('logging errorlog').text.should == "error.log" + directory.css('logging loglevel').text.should == "4" + directory.css('logging playlistlog').text.should == "playlist.log" + end end \ No newline at end of file diff --git a/ruby/spec/jam_ruby/models/icecast_path_spec.rb b/ruby/spec/jam_ruby/models/icecast_path_spec.rb index 9b8a04c27..58f3f458a 100644 --- a/ruby/spec/jam_ruby/models/icecast_path_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_path_spec.rb @@ -3,14 +3,24 @@ require 'spec_helper' describe IcecastPath do let(:iobj) { IcecastPath.new } - - before(:all) do - - end + let(:output) { StringIO.new } it "save" do iobj.save.should be_true - iobj.dumpXml + iobj.dumpXml(1, output) + + output.rewind + directory = Nokogiri::XML(output) + directory.css('paths basedir').text.should == "./" + directory.css('paths logdir').text.should == "./logs" + directory.css('paths pidfile').text.should == "./icecast.pid" + directory.css('paths webroot').text.should == "./web" + directory.css('paths adminroot').text.should == "./admin" + directory.css('paths allow-ip').text.should == "/path/to/ip_allowlist" + directory.css('paths deny-ip').text.should == "/path_to_ip_denylist" + directory.css('paths alias').text.should == "" + #puts directory.css('paths alias').first["source"] + end end \ No newline at end of file diff --git a/ruby/spec/jam_ruby/models/icecast_security_spec.rb b/ruby/spec/jam_ruby/models/icecast_security_spec.rb index c94be6b5f..52859aa3a 100644 --- a/ruby/spec/jam_ruby/models/icecast_security_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_security_spec.rb @@ -3,17 +3,26 @@ require 'spec_helper' describe IcecastSecurity do let(:iobj) { IcecastSecurity.new } + let(:output) { StringIO.new } - before(:all) do +=begin +example output: - end + + 0 + + hotdog + mongrel + + +=end it "save" do iobj.changeowner_user ="hotdog" iobj.changeowner_group ="mongrel" iobj.save.should be_true - iobj.dumpXml + iobj.dumpXml(1, output) end diff --git a/ruby/spec/jam_ruby/models/icecast_user_authentication_spec.rb b/ruby/spec/jam_ruby/models/icecast_user_authentication_spec.rb index 4c960d008..147b9b0a7 100644 --- a/ruby/spec/jam_ruby/models/icecast_user_authentication_spec.rb +++ b/ruby/spec/jam_ruby/models/icecast_user_authentication_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe IcecastUserAuthentication do let(:iobj) { IcecastUserAuthentication.new } + let(:output) { StringIO.new } before(:all) do @@ -11,7 +12,7 @@ describe IcecastUserAuthentication do it "save" do iobj.save #puts iobj.inspect - iobj.dumpXml + iobj.dumpXml(1, output) iobj.errors.any?.should be_false end @@ -23,7 +24,7 @@ describe IcecastUserAuthentication do #puts limit.inspect iobj.filename ="/dfdfd