Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Forked from andyl/user_spec.rb
Created May 12, 2011 00:51
Show Gist options
  • Save bcardarella/967720 to your computer and use it in GitHub Desktop.
Save bcardarella/967720 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe User do
describe "Object Attributes" do
before(:each) { @obj = User.new }
specify { @obj.should respond_to(:first_name) }
specify { @obj.should respond_to(:last_name) }
specify { @obj.should respond_to(:login) }
end
describe "Associations" do
before(:each) { @obj = User.new }
specify { @obj.should respond_to(:addresses) }
specify { @obj.should respond_to(:phones) }
specify { @obj.should respond_to(:emails) }
specify { @obj.should respond_to(:roles) }
specify { @obj.should respond_to(:photos) }
specify { @obj.should respond_to(:do_avails) }
specify { @obj.should respond_to(:messages) }
specify { @obj.should respond_to(:distributions) }
end
describe "Validations" do
it { should have_valid(:first_name).when("Joe", "J x", "J.x") }
it { should_not have_valid(:first_name).when("", "J_x") }
it { should have_valid(:last_name).when("Smith") }
it { should_not have_valid(:last_name).when("") }
it { should have_valid(:login).when("joe.smith") }
it { should_not have_valid(:login).when("") }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment