Created
August 25, 2009 22:29
-
-
Save joahking/175083 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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