-
-
Save h-lame/292743 to your computer and use it in GitHub Desktop.
This file contains 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
# something like ... | |
# I think this goes in specs/support/whatever.rb | |
def it_should_be_invalid_without(*fields) | |
object_name = described_class.name.underscore | |
fields.each do |field| | |
it "should fail if #{field} is missing" do | |
instance_variable_get("@#{object_name}").send(:"#{field}=", nil) | |
instance_variable_get("@#{object_name}").should_not be_valid_for_create | |
end | |
end | |
end | |
# and you use this in your specs... | |
it_should_be_invalid_without :title, | |
:first_name, :last_name, | |
:country_id, :address1, | |
:address3, :postcode, | |
:username, :email, | |
:password, :password_confirmation, | |
:currency_id, | |
:security_question_id1, | |
:security_question_answer1 | |
This file contains 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment