From fda1b9b3d83de57c4bbdea744ef6e8d28b0b8007 Mon Sep 17 00:00:00 2001 From: studio3104 Date: Tue, 7 May 2013 18:54:32 +0900 Subject: [PATCH] fixed a bug of be_mounted matcher --- lib/serverspec/backend/exec.rb | 2 +- spec/support/shared_matcher_examples.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/serverspec/backend/exec.rb b/lib/serverspec/backend/exec.rb index 0c989bcb..b5e1331b 100644 --- a/lib/serverspec/backend/exec.rb +++ b/lib/serverspec/backend/exec.rb @@ -140,7 +140,7 @@ def check_mounted(example, path, expected_attr, only_with) else match = true expected_attr.each do |key, val| - match = actual_attr[key] == val + return false if actual_attr[key] != val end match end diff --git a/spec/support/shared_matcher_examples.rb b/spec/support/shared_matcher_examples.rb index 2bdc9ddf..c2e9b931 100644 --- a/spec/support/shared_matcher_examples.rb +++ b/spec/support/shared_matcher_examples.rb @@ -155,6 +155,10 @@ it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } end + describe valid_mount do + it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } + end + describe valid_mount do it { should_not be_mounted.with( :type => 'xfs' ) } end @@ -167,6 +171,14 @@ it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } end + describe valid_mount do + it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } + end + + describe valid_mount do + it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } + end + describe '/etc/thid_is_a_invalid_mount' do it { should_not be_mounted.with( :type => 'ext4' ) } end