Sha256: ca2ff9ac81c514f126193c026d843eab94f3f55181ac1f4bc4535ba2e0afc60f
Contents?: true
Size: 1.93 KB
Versions: 4
Compression:
Stored size: 1.93 KB
Contents
require 'generator_spec/rails_helpers/rails_model' module RSpec::Rails module Orm module Base include RSpec::Rails::Model protected def document_name type type_content = type == :document ? "#{orm_name}::Document" : "#{orm_name}::EmbeddedDocument" end def clazz name "class #{name.to_s.camelize}" end def file name %Q{#{clazz name} #{yield if block_given?} end} end def file_w_include name file name { "include #{yield}" if block_given?} end def file_w_inherit name %Q{#{clazz name} < #{yield if block_given?} end} end def field name, type = nil return "#{field_name} :#{name}, #{type}" if type "#{field_name} :#{name}" end end module ActiveRecord include RSpec::Rails::Orm::Base def file_content name, type=nil file_w_inherit(name) {'ActiveRecord::Base'} end end module MongoMapper include RSpec::Rails::Orm::Base def orm_name 'MongoMapper' end def file_content name, type = :document file_w_include(name) { document_name type } end def field_name 'key' end end module Mongoid include RSpec::Rails::Orm::Base def orm_name 'Mongoid' end def field_name 'field' end def file_content name, type = :document file_w_include(name) { document_name type } end def field name, type = nil return "#{field_name} :#{name}, :type => #{type}" if type "#{field_name} :#{name}" end end module DataMapper include RSpec::Rails::Orm::Base def orm_name 'DataMapper' end def file_content name file_w_include(name) { "#{orm_name}::Resource" } end def field_name 'property' end end end end
Version data entries
4 entries across 4 versions & 1 rubygems