Revisions
-
h-lame revised this gist
Feb 2, 2010 . 1 changed file with 26 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,26 @@ # 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 -
rlivsey created this gist
Feb 2, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ [ :title, :first_name, :last_name, :country_id, :address1, :address3, :postcode, :username, :email, :password, :password_confirmation, :currency_id, :security_question_id1, :security_question_answer1].each do |field| it "should fail if #{field} is missing" do @account.send(:"#{field}=", nil) @account.should_not be_valid_for_create end end Empty file.