spec/support/shared_matcher_examples.rb in serverspec-0.2.19 vs spec/support/shared_matcher_examples.rb in serverspec-0.2.20

- old
+ new

@@ -92,10 +92,153 @@ it { should_not be_listening } end end end +shared_examples_for 'support be_mounted matcher' do |valid_mount| + describe 'be_mounted' do + describe valid_mount do + it { should be_mounted } + end + + describe '/etc/thid_is_a_invalid_mount' do + it { should_not be_mounted } + end + end +end + +shared_examples_for 'support be_mounted.with matcher' do |valid_mount| + describe 'be_mounted.with' do + before :all do + RSpec.configure do |c| + c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" + end + end + + describe valid_mount do + it { should be_mounted.with( :type => 'ext4' ) } + end + + describe valid_mount do + it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } + end + + describe valid_mount do + it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } + end + + describe valid_mount do + it { should_not be_mounted.with( :type => 'xfs' ) } + end + + describe valid_mount do + it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } + end + + describe valid_mount do + it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } + end + + describe '/etc/thid_is_a_invalid_mount' do + it { should_not be_mounted.with( :type => 'ext4' ) } + end + end +end + + +shared_examples_for 'support be_mounted.only_with matcher' do |valid_mount| + describe 'be_mounted.with' do + before :all do + RSpec.configure do |c| + c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" + end + end + + describe valid_mount do + it do + should be_mounted.only_with( + :device => '/dev/mapper/VolGroup-lv_root', + :type => 'ext4', + :options => { + :rw => true, + :mode => 620, + } + ) + end + end + + describe valid_mount do + it do + should_not be_mounted.only_with( + :device => '/dev/mapper/VolGroup-lv_root', + :type => 'ext4', + :options => { + :rw => true, + :mode => 620, + :bind => true, + } + ) + end + end + + describe valid_mount do + it do + should_not be_mounted.only_with( + :device => '/dev/mapper/VolGroup-lv_root', + :type => 'ext4', + :options => { + :rw => true, + } + ) + end + end + + describe valid_mount do + it do + should_not be_mounted.only_with( + :device => '/dev/mapper/VolGroup-lv_roooooooooot', + :type => 'ext4', + :options => { + :rw => true, + :mode => 620, + } + ) + end + end + + describe '/etc/thid_is_a_invalid_mount' do + it { should_not be_mounted.only_with( :type => 'ext4' ) } + end + end +end + + +shared_examples_for 'support be_resolvable matcher' do |valid_name| + describe 'be_resolvable' do + describe valid_name do + it { should be_resolvable } + end + + describe 'invalid_name' do + it { should_not be_resolvable } + end + end +end + + +shared_examples_for 'support be_resolvable.by matcher' do |valid_name, type| + describe 'be_resolvable.by' do + describe valid_name do + it { should be_resolvable.by(type) } + end + + describe 'invalid_name' do + it { should_not be_resolvable.by(type) } + end + end +end + shared_examples_for 'support be_file matcher' do |valid_file| describe 'be_file' do describe valid_file do it { should be_file } end @@ -905,6 +1048,6 @@ context param do its(:value) { should_not match /invalid-string/ } end end -end \ No newline at end of file +end