[icinga-checkins] icinga.org: chef-icinga2/master: rubocop

git at icinga.org git at icinga.org
Tue Jul 19 18:21:15 CEST 2016


Module: chef-icinga2
Branch: master
Commit: c7536dbd60c96825d86a2ba7d18aadbf91ea42c1
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=c7536dbd60c96825d86a2ba7d18aadbf91ea42c1

Author: Virender Khatri <vir.khatri at gmail.com>
Date:   Tue Jul 19 22:09:06 2016 +0530

rubocop

---

 libraries/icinga2.rb     |   16 ++++++++--------
 spec/unit/helper_spec.rb |   33 ++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/libraries/icinga2.rb b/libraries/icinga2.rb
index 1dafe49..ad8ef1a 100644
--- a/libraries/icinga2.rb
+++ b/libraries/icinga2.rb
@@ -22,9 +22,9 @@ end
 def icinga_format(toplevel)
   case toplevel
   when Hash
-  rval = "{ "
+    rval = '{ '
   when Array
-  rval = "[ "
+    rval = '[ '
   when NilClass
     return 'null'
   when String, Float, Fixnum
@@ -35,14 +35,14 @@ def icinga_format(toplevel)
     return toplevel.inspect.to_s.inspect
   end
 
-  rval += toplevel.collect do |k,v|
+  rval += toplevel.collect do |k, v|
     prefix = ''
 
     target = k
     case toplevel
     when Hash
-        prefix += "#{icinga_format(k)} = "
-        target = v
+      prefix += "#{icinga_format(k)} = "
+      target = v
     end
 
     prefix += icinga_format(target)
@@ -50,10 +50,10 @@ def icinga_format(toplevel)
 
   case toplevel
   when Hash
-  rval += " }"
+    rval += ' }'
   when Array
-  rval += " ]"
+    rval += ' ]'
   end
 
-  return rval
+  rval
 end
diff --git a/spec/unit/helper_spec.rb b/spec/unit/helper_spec.rb
index 720e74c..c9156c6 100644
--- a/spec/unit/helper_spec.rb
+++ b/spec/unit/helper_spec.rb
@@ -2,43 +2,42 @@
 # This seems wrong, but I don't actually know how to do this
 require_relative '../../libraries/icinga2.rb'
 
-describe "#icinga_format" do
+describe '#icinga_format' do
   subject { icinga_format }
 
-  it "handles hashes" do
-    expect(icinga_format({:foo => :bar})).to eq('{ "foo" = "bar" }')
+  it 'handles hashes' do
+    expect(icinga_format(:foo => :bar)).to eq('{ "foo" = "bar" }')
   end
 
-  it "handles arrays" do
-    expect(icinga_format([1,3,5])).to eq('[ 1, 3, 5 ]')
+  it 'handles arrays' do
+    expect(icinga_format([1, 3, 5])).to eq('[ 1, 3, 5 ]')
   end
 
-  it "handles strings" do
-    expect(icinga_format("foo")).to eq('"foo"')
+  it 'handles strings' do
+    expect(icinga_format('foo')).to eq('"foo"')
   end
 
-  it "handles floats" do
+  it 'handles floats' do
     expect(icinga_format(1.2)).to eq('1.2')
   end
 
-  it "handles fixnums" do
+  it 'handles fixnums' do
     expect(icinga_format(10)).to eq('10')
   end
 
-  it "handles nulls" do
-    expect(icinga_format(nil)).to eq("null")
+  it 'handles nulls' do
+    expect(icinga_format(nil)).to eq('null')
   end
 
-  it "handles nesting" do
-    expect(icinga_format({:foo => [:bar, {1=>2}, {1=>[:a,:b,:c]}]})).to eq('{ "foo" = [ "bar", { 1 = 2 }, { 1 = [ "a", "b", "c" ] } ] }')
+  it 'handles nesting' do
+    expect(icinga_format(:foo => [:bar, { 1 => 2 }, { 1 => [:a, :b, :c] }])).to eq('{ "foo" = [ "bar", { 1 = 2 }, { 1 = [ "a", "b", "c" ] } ] }')
   end
 
-  it "handles arbitrary objects by stringifying them" do
+  it 'handles arbitrary objects by stringifying them' do
     expect(icinga_format(StandardError.new)).to eq('"#<StandardError: StandardError>"')
   end
 
-  it "Arbitrary stringifying works with nesting" do
-    expect(icinga_format({"err"=>StandardError.new, "list"=>[{"err"=>IOError.new}]})).to eq('{ "err" = "#<StandardError: StandardError>", "list" = [ { "err" = "#<IOError: IOError>" } ] }')
+  it 'Arbitrary stringifying works with nesting' do
+    expect(icinga_format('err' => StandardError.new, 'list' => [{ 'err' => IOError.new }])).to eq('{ "err" = "#<StandardError: StandardError>", "list" = [ { "err" = "#<IOError: IOError>" } ] }')
   end
-
 end



More information about the icinga-checkins mailing list