spec/spec_helper.rb in gbdev-pdf_filler-0.2.0 vs spec/spec_helper.rb in gbdev-pdf_filler-0.3.0
- old
+ new
@@ -39,18 +39,67 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'pdf_filler'
+
+module GBDev
+ module TestData
+ module Addresses
+ def create_corpus!
+ create!(:address1 => '111 AAA St', :address2 => 'Suite 444', :city => 'Reno', :state => 'Nevada', :postal_code => '89506')
+ create!(:address1 => '222 BBB St', :address2 => 'Suite 555', :city => 'Sparks', :state => 'Nevada', :postal_code => '89434')
+ create!(:address1 => '333 CCC St', :address2 => 'Suite 666', :city => 'Fernley', :state => 'Nevada', :postal_code => '89408')
+ end
+ end
+ end
+end
+
+
Spec::Runner.configure do |config|
config.before(:each) do
class Client < ActiveRecord::Base
+ acts_as_pdf_db_mapper :only => [:first_name, :last_name]
has_many :addresses, :dependent => :destroy
+
+ def full_name
+ [self.first_name, self.last_name].join(' ')
+ end
end
class Address < ActiveRecord::Base
- belongs_to :client
+ acts_as_pdf_db_mapper
+ belongs_to :client
+ extend GBDev::TestData::Addresses
end
+
+ class ClientAddress < ActiveRecord::Base
+ set_table_name :addresses
+ acts_as_pdf_db_mapper :only => [:state, :city]
+ end
+
+ class ContactAddress < ActiveRecord::Base
+ set_table_name :addresses
+ acts_as_pdf_db_mapper :except => [:id, :address1, :postal_code]
+ end
+
+ class UserAddress < ActiveRecord::Base
+ set_table_name :addresses
+ acts_as_pdf_db_mapper :include => [{:full_address => :address}]
+
+ def full_address
+ [self.address1, self.address2].join(', ')
+ end
+ end
+
+ class FamilyAddress < ActiveRecord::Base
+ set_table_name :addresses
+ acts_as_pdf_db_mapper :only_include => [{:full_address => :address}]
+
+ def full_address
+ [self.address1, self.address2].join(', ')
+ end
+ end
Client.destroy_all
Address.destroy_all
end