serverspec 0.2.15 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,10 @@ module Serverspec
7
7
  %w( abi crypto debug dev fs kernel net sunrpc vm ).each do |param|
8
8
  if description_args.match(/^#{param}\./)
9
9
  ret = backend(Serverspec::Commands::Base).do_check("sysctl -q -n #{description_args}")
10
+ val = ret[:stdout].strip
11
+ val = val.to_i if val.match(/^\d+$/)
10
12
  subject = Serverspec::Subject.new
11
- subject.value(ret[:stdout].strip.to_i)
13
+ subject.value(val)
12
14
  return subject
13
15
  end
14
16
  end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.2.15"
2
+ VERSION = "0.2.16"
3
3
  end
@@ -58,5 +58,7 @@ describe 'Serverspec matchers of Debian family', :os => :debian do
58
58
  it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
59
59
  it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
60
60
 
61
- it_behaves_like 'support linux kernel parameter checking', 'net.ipv4.tcp_syncookies'
61
+ it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
62
+ it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
63
+ it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
62
64
  end
@@ -59,5 +59,7 @@ describe 'Serverspec matchers of Gentoo family', :os => :gentoo do
59
59
  it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
60
60
  it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
61
61
 
62
- it_behaves_like 'support linux kernel parameter checking', 'net.ipv4.tcp_syncookies'
62
+ it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
63
+ it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
64
+ it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
63
65
  end
@@ -64,5 +64,7 @@ describe 'Serverspec matchers of Red Hat family', :os => :redhat do
64
64
  it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
65
65
  it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
66
66
 
67
- it_behaves_like 'support linux kernel parameter checking', 'net.ipv4.tcp_syncookies'
67
+ it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
68
+ it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
69
+ it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
68
70
  end
@@ -791,20 +791,56 @@ shared_examples_for 'support return_stderr matcher with regexp' do |command, con
791
791
  end
792
792
  end
793
793
 
794
- shared_examples_for 'support linux kernel parameter checking' do |param|
794
+ shared_examples_for 'support linux kernel parameter checking with integer' do |param, value|
795
795
  describe 'linux kernel parameter' do
796
796
  before :all do
797
797
  RSpec.configure do |c|
798
- c.stdout = "1\n"
798
+ c.stdout = "#{value}\n"
799
799
  end
800
800
  end
801
801
 
802
802
  context param do
803
- its(:value) { should eq 1 }
803
+ its(:value) { should eq value }
804
804
  end
805
805
 
806
806
  context param do
807
- its(:value) { should_not eq 0 }
807
+ its(:value) { should_not eq value + 1 }
808
+ end
809
+ end
810
+ end
811
+
812
+ shared_examples_for 'support linux kernel parameter checking with string' do |param, value|
813
+ describe 'linux kernel parameter' do
814
+ before :all do
815
+ RSpec.configure do |c|
816
+ c.stdout = "#{value}\n"
817
+ end
818
+ end
819
+
820
+ context param do
821
+ its(:value) { should eq value }
822
+ end
823
+
824
+ context param do
825
+ its(:value) { should_not eq value + '_suffix' }
826
+ end
827
+ end
828
+ end
829
+
830
+ shared_examples_for 'support linux kernel parameter checking with regexp' do |param, regexp|
831
+ describe 'linux kernel parameter' do
832
+ before :all do
833
+ RSpec.configure do |c|
834
+ c.stdout = "4096 16384 4194304\n"
835
+ end
836
+ end
837
+
838
+ context param do
839
+ its(:value) { should match regexp }
840
+ end
841
+
842
+ context param do
843
+ its(:value) { should_not match /invalid-string/ }
808
844
  end
809
845
  end
810
846
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh