Skip to content

Instantly share code, notes, and snippets.

View mattetti's full-sized avatar

Matt Aimonetti mattetti

View GitHub Profile
require File.join( File.dirname(__FILE__), '..', "spec_helper" )
describe Client do
it "should have a valid factory" do
Factory.build(:client).should be_valid
end
it "should not be valid without a name" do
Factory.build(:client, :name => nil).should_not be_valid
class Client
include DataMapper::Resource
property :id, Integer, :serial => true
property :name, String
property :email, String
property :city, String, :lazy => true
property :zip_code, String, :field => 'postal_code', :lazy => true
property :phone, String, :lazy => true
property :address, String, :lazy => true
# Client factory
Factory.define :client do |c|
c.name 'John Doe'
c.email{|c| "#{(c.name || "John Doe").split(' ').first}.#{(c.name || "John Doe").split(' ').last}@email.com".downcase}
c.address "1234 DrPepper Road"
c.city "San Diego"
c.zip_code "92129"
c.phone "858-555-1234"
c.created_at Time.now
end
class Client
include DataMapper::Resource
property :id, Integer, :serial => true
property :name, String
property :email, String
property :city, String, :lazy => true
property :zip_code, String, :field => 'postal_code', :lazy => true
property :phone, String, :lazy => true
property :address, String, :lazy => true
require File.join( File.dirname(__FILE__), '..', "spec_helper" )
describe Client do
before(:each) do
Client.all.destroy!
end
it "should have a valid factory" do
Factory.build(:client).should be_valid
# note that we are declaring the 2 following dependencies in init.rb:
# dependencies "dm-validations"
# dependencies "dm-timestamps"
class Client
include DataMapper::Resource
property :id, Integer, :serial => true
property :name, String, :length => 3..150
property :email, String
# Client factory
Factory.define :client do |c|
c.name 'John Doe'
c.email{|c| "#{(c.name || "John Doe").split(' ').first}.#{(c.name || "John Doe").split(' ').last}@email.com".downcase}
c.address "1234 DrPepper Road"
c.city "San Diego"
c.zip_code "92129"
c.phone "858-555-1234"
c.created_at Time.now
end
require File.join( File.dirname(__FILE__), '..', "spec_helper" )
describe Client do
it "should have a valid factory" do
Factory.build(:client).should be_valid
end
it "should not be valid without a name" do
Factory.build(:client, :name => nil).should_not be_valid
class Client
include DataMapper::Resource
property :id, Integer, :serial => true
property :name, String
property :email, String
property :city, String, :lazy => true
property :zip_code, String, :field => 'postal_code', :lazy => true
property :phone, String, :lazy => true
property :address, String, :lazy => true
# Client factory
Factory.define :client do |c|
c.name 'John Doe'
c.email{|c| "#{(c.name || "John Doe").split(' ').first}.#{(c.name || "John Doe").split(' ').last}@email.com".downcase}
c.address "1234 DrPepper Road"
c.city "San Diego"
c.zip_code "92129"
c.phone "858-555-1234"
c.created_at Time.now
end