Skip to content

Instantly share code, notes, and snippets.

@joahking
Created August 25, 2009 22:29
Show Gist options
  • Save joahking/175083 to your computer and use it in GitHub Desktop.
Save joahking/175083 to your computer and use it in GitHub Desktop.
# now there is no metaprogramming involve, but finger saving it is indeed :-)
describe 'active ones' do
it 'should require required attributes' do
REQUIRED_ATTRS = [ :email, :name, :birthday, :phone, :address, :city,
:province, :postal_code,
:country, :nationality,
:employment_status ] unless defined?(REQUIRED_ATTRS)
Candidate.new.attribute_names.each do |attr|
#we need a clean state, since shoulda could be changing the object
candidate = Candidate.make_active
if REQUIRED_ATTRS.include? attr.to_sym
candidate.should validate_presence_of(attr)
else
candidate.should_not validate_presence_of(attr)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment