spec/support/shared_matcher_examples.rb in serverspec-0.2.15 vs spec/support/shared_matcher_examples.rb in serverspec-0.2.16
- old
+ new
@@ -789,22 +789,58 @@
it { should_not return_stdout(content) }
end
end
end
-shared_examples_for 'support linux kernel parameter checking' do |param|
+shared_examples_for 'support linux kernel parameter checking with integer' do |param, value|
describe 'linux kernel parameter' do
before :all do
RSpec.configure do |c|
- c.stdout = "1\n"
+ c.stdout = "#{value}\n"
end
end
context param do
- its(:value) { should eq 1 }
+ its(:value) { should eq value }
end
context param do
- its(:value) { should_not eq 0 }
+ its(:value) { should_not eq value + 1 }
+ end
+ end
+end
+
+shared_examples_for 'support linux kernel parameter checking with string' do |param, value|
+ describe 'linux kernel parameter' do
+ before :all do
+ RSpec.configure do |c|
+ c.stdout = "#{value}\n"
+ end
+ end
+
+ context param do
+ its(:value) { should eq value }
+ end
+
+ context param do
+ its(:value) { should_not eq value + '_suffix' }
+ end
+ end
+end
+
+shared_examples_for 'support linux kernel parameter checking with regexp' do |param, regexp|
+ describe 'linux kernel parameter' do
+ before :all do
+ RSpec.configure do |c|
+ c.stdout = "4096 16384 4194304\n"
+ end
+ end
+
+ context param do
+ its(:value) { should match regexp }
+ end
+
+ context param do
+ its(:value) { should_not match /invalid-string/ }
end
end
end