Skip to content

Instantly share code, notes, and snippets.

@danielsdeleo
Created September 5, 2009 21:55
Show Gist options
  • Select an option

  • Save danielsdeleo/181529 to your computer and use it in GitHub Desktop.

Select an option

Save danielsdeleo/181529 to your computer and use it in GitHub Desktop.
class << self
def resource_has_a_string_attribute(attr_name)
it "has a String attribute for #{attr_name.to_s}" do
@resource.send(attr_name, "this is a string")
@resource.send(attr_name).should eql("this is a string")
lambda {@resource.send(attr_name, 8675309)}.should raise_error(ArgumentError)
end
end
def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false})
it "has a Boolean attribute for #{attr_name.to_s}" do
@resource.send(attr_name).should eql(opts[:defaults_to])
@resource.send(attr_name, !opts[:defaults_to])
@resource.send(attr_name).should eql( !opts[:defaults_to] )
end
end
end
before do
@resource = Chef::Resource::Deploy.new("/my/deploy/dir")
end
resource_has_a_string_attribute(:repo)
resource_has_a_string_attribute(:role)
resource_has_a_string_attribute(:restart_command)
resource_has_a_string_attribute(:migration_command)
resource_has_a_string_attribute(:user)
resource_has_a_string_attribute(:group)
resource_has_a_string_attribute(:repository_cache)
resource_has_a_string_attribute(:copy_exclude)
resource_has_a_string_attribute(:revision)
resource_has_a_string_attribute(:git_ssh_wrapper)
resource_has_a_string_attribute(:svn_username)
resource_has_a_string_attribute(:svn_password)
resource_has_a_boolean_attribute(:migrate, :defaults_to=>false)
resource_has_a_boolean_attribute(:enable_submodules, :defaults_to=>false)
resource_has_a_boolean_attribute(:shallow_clone, :defaults_to=>false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment