spec/sprinkle/verify_spec.rb in sprinkle-0.7.2 vs spec/sprinkle/verify_spec.rb in sprinkle-0.7.3
- old
+ new
@@ -52,33 +52,62 @@
has_gem 'rails'
has_gem 'rails', '2.1.0'
# Check for a certain RPM package
has_rpm 'ntp'
+
+ belongs_to_user "/etc/", "me"
+ belongs_to_user "/etc/", 2
+ belongs_to_group "/etc/", "root"
+ belongs_to_group "/etc/", 0
end
end
@verification = @package.verifications[0]
- @delivery = mock(Sprinkle::Deployment, :process => true)
+ @delivery = mock(Sprinkle::Deployment, :process => true, :sudo_command => "sudo")
@verification.delivery = @delivery
end
+
+ describe "with sudo" do
+ before do
+ @package = package @name do
+ use_sudo true
+ gem 'nonexistent'
+ verify 'moo' do
+ md5_of_file "/etc/secret", "123abc"
+ end
+ end
+ @verification = @package.verifications[0]
+ @verification.delivery = @delivery
+ end
+ it "should run sudo when necessary" do
+ @verification.commands.should include(%{test "`sudo md5sum /etc/secret | cut -f1 -d' '`" = "123abc"})
+ end
+ end
describe 'when created' do
it 'should raise error without a block' do
lambda { Verify.new(nil, '') }.should raise_error
end
end
describe 'with checks' do
+ it "should test that a file belongs to a given user or group" do
+ @verification.commands.should include("find /etc/ -maxdepth 0 -user me | egrep '.*'")
+ @verification.commands.should include("find /etc/ -maxdepth 0 -uid 2 | egrep '.*'")
+ @verification.commands.should include("find /etc/ -maxdepth 0 -group root | egrep '.*'")
+ @verification.commands.should include("find /etc/ -maxdepth 0 -gid 0 | egrep '.*'")
+ end
+
it 'should do a "test -f" on the has_file check' do
@verification.commands.should include('test -f my_file.txt')
end
it 'should do a grep to see if a file contains a text string' do
@verification.commands.should include("grep 'A sunny day on the lower east-side' my_file.txt")
end
it 'should do a md5sum to see if a file matches local file' do
- @verification.commands.should include(%{[ "X$(md5sum my_file.txt|cut -d\\ -f 1)" = "Xed20d984b757ad5291963389fc209864" ]})
+ @verification.commands.should include(%{test "`md5sum my_file.txt | cut -f1 -d' '`" = "ed20d984b757ad5291963389fc209864"})
end
it 'should do a "test -d" on the has_directory check' do
@verification.commands.should include('test -d mydir')
end