Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from anonymous/snippet.rb
Created July 16, 2010 11:36
Show Gist options
  • Select an option

  • Save radar/478257 to your computer and use it in GitHub Desktop.

Select an option

Save radar/478257 to your computer and use it in GitHub Desktop.
# Validations
validates_presence_of :email, :unless => Proc.new { |user| user.email.blank? }
validates_presence_of :username, :unless => :registered_with_email?
def registered_with_username?
self.username.blank?
end
describe Account, "created" do
describe "with username and password" do
subject { Factory.build(:account, :email => nil) }
it { should be_valid }
end
describe "with email and password" do
subject { Factory.build(:account, :username => nil) }
it { should be_valid }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment