Skip to content

Commit

Permalink
Woo
Browse files Browse the repository at this point in the history
  • Loading branch information
wfarr committed Sep 6, 2011
1 parent add19f4 commit 3706124
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rspec
@@ -1 +1 @@
--color
--color --format documentation
18 changes: 17 additions & 1 deletion lib/vagabond/matchers/file.rb
@@ -1,9 +1,25 @@
require 'etc'

module Vagabond
module Matchers
module File
RSpec::Matchers.define :exist do
match do |actual|
::File.exist? actual.name
::File.exist? actual
end

failure_message_for_should do |actual|
"expected file(#{actual}) would exist"
end

failure_message_for_should_not do |actual|
"expected file(#{actual}) would not exist"
end
end

RSpec::Matchers.define :have_owner do |expected|
match do |actual|
::Etc.getpwuid(::File.stat(actual).uid).name == expected
end
end
end
Expand Down
9 changes: 8 additions & 1 deletion lib/vagabond/resources/file.rb
@@ -1,7 +1,7 @@
module Vagabond
module Resources
class File
attr_accessor :name, :owner, :group
attr_accessor :name, :owner, :group, :path

def initialize(name, options = {})
@name = name
Expand All @@ -11,6 +11,13 @@ def initialize(name, options = {})
if options[:group]
@group = options[:group]
end
if options[:path]
@path = options[:path]
end
end

def to_s
@path || @name
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/file_spec.rb
Expand Up @@ -6,4 +6,8 @@

describe file("/etc/motd") do
it { should_not exist }
end

describe file("~/.git/config") do
it { should have_owner('wfarr') }
end

0 comments on commit 3706124

Please sign in to comment.