Sha256: c86972e2bd24f2275a70a8fe054707bbd28129828e8ba96d82f40c1826228bb1

Contents?: true

Size: 1.36 KB

Versions: 13

Compression:

Stored size: 1.36 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'active_record'
require 'mongoid'
require 'phony_rails'

ActiveRecord::Base.establish_connection(
  :adapter  => "sqlite3",
  :database => ":memory:"
)

ActiveRecord::Schema.define do
  create_table :active_record_models do |table|
    table.column :phone_attribute, :string
    table.column :phone_number, :string
    table.column :phone_number_as_normalized, :string
  end
end

module SharedModelMethods
  extend ActiveSupport::Concern
  included do
    attr_accessor :phone_method, :phone1_method, :country_code
    phony_normalized_method :phone_attribute # adds normalized_phone_attribute method
    phony_normalized_method :phone_method # adds normalized_phone_method method
    phony_normalized_method :phone1_method, :default_country_code => 'DE' # adds normalized_phone_method method
    phony_normalize :phone_number # normalized on validation
  end
end

class ActiveRecordModel < ActiveRecord::Base
  include SharedModelMethods
end

class ActiveRecordDummy < ActiveRecordModel
end

class MongoidModel
  include Mongoid::Document
  include Mongoid::Phony
  field :phone_attribute, :type => String
  field :phone_number,    :type => String
  field :phone_number_as_normalized, :type => String
  include SharedModelMethods
end

class MongoidDummy < MongoidModel
end

RSpec.configure do |config|
  # some (optional) config here
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
phony_rails-0.8.1 spec/spec_helper.rb
phony_rails-0.8.0 spec/spec_helper.rb
phony_rails-0.7.3 spec/spec_helper.rb
phony_rails-0.7.2 spec/spec_helper.rb
phony_rails-0.7.1 spec/spec_helper.rb
phony_rails-0.7.0 spec/spec_helper.rb
phony_rails-0.6.2 spec/spec_helper.rb
phony_rails-0.6.1 spec/spec_helper.rb
phony_rails-0.6.0 spec/spec_helper.rb
phony_rails-0.5.0 spec/spec_helper.rb
phony_rails-0.4.2 spec/spec_helper.rb
phony_rails-0.4.1 spec/spec_helper.rb
phony_rails-0.4.0 spec/spec_helper.rb