Skip to content

Instantly share code, notes, and snippets.

@andyl
Created May 11, 2011 23:33
Show Gist options
  • Save andyl/967629 to your computer and use it in GitHub Desktop.
Save andyl/967629 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") }
it { should_not have_valid(:first_name).when("") }
it { should have_valid(:first_name).when("J x") }
it { should have_valid(:first_name).when("J.x") }
it { should_not have_valid(:first_name).when("J_x") }
it { should_not have_valid(:first_name).when("") }
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