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 characters
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 |
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 characters
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 |
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 characters
# 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 |
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 characters
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 |
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 characters
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 |
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 characters
# 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 |
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 characters
# 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 |
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 characters
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 |
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 characters
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 |
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 characters
# 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 |