object-daddy 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -3,7 +3,7 @@ module ObjectDaddy
3
3
  def self.included(klass)
4
4
  klass.extend ClassMethods
5
5
  if defined? ActiveRecord and klass < ActiveRecord::Base
6
- klass.extend RailsClassMethods
6
+ klass.extend ActiveRecordClassMethods
7
7
 
8
8
  class << klass
9
9
  alias_method :validates_presence_of_without_object_daddy, :validates_presence_of
@@ -130,7 +130,7 @@ module ObjectDaddy
130
130
 
131
131
  protected
132
132
 
133
- # we define an underscore helper ourselves since the ActiveSupport isn't available if we're not using Rails
133
+ # we define an underscore helper ourselves since the ActiveSupport isn't available if we're not using AR
134
134
  def underscore(string)
135
135
  string.gsub(/([a-z])([A-Z])/, '\1_\2').gsub(/::/,'_').downcase
136
136
  end
@@ -186,9 +186,9 @@ module ObjectDaddy
186
186
  (presence_validated_attributes.keys - args.keys).each {|a| req[a.to_s] = true } # find attributes required by validates_presence_of not already set
187
187
 
188
188
  belongs_to_associations = reflect_on_all_associations(:belongs_to).to_a
189
- fk_method = Rails.version >= "3.1.0" ? :foreign_key : :primary_key_name
189
+ fk_method = ActiveRecord::VERSION::STRING >= "3.1.0" ? :foreign_key : :primary_key_name
190
190
  missing = belongs_to_associations.select { |a| req[a.name.to_s] or req[a.send(fk_method).to_s] }
191
- # Rails 3.1 compatibility jazz - current_scoped_methods was deprecated.
191
+ # AR 3.1 compatibility jazz - current_scoped_methods was deprecated.
192
192
  if scope = respond_to?(:current_scoped_methods) ? current_scoped_methods : current_scope
193
193
  missing.reject! { |a| scope.scope_for_create.include?(a.send(fk_method)) }
194
194
  end
@@ -198,11 +198,19 @@ module ObjectDaddy
198
198
  end
199
199
  end
200
200
 
201
- module RailsClassMethods
201
+ module ActiveRecordClassMethods
202
+ def root_dir
203
+ if defined? Rails
204
+ Rails.root
205
+ else
206
+ ENV['ROOT_DIR'] || ENV['PWD']
207
+ end
208
+ end
209
+
202
210
  def exemplar_path
203
211
  ['spec', 'test'].inject([]) do |array, dir|
204
- if File.directory?(File.join(Rails.root, dir))
205
- array << File.join(Rails.root, dir, 'exemplars')
212
+ if File.directory?(File.join(root_dir, dir))
213
+ array << File.join(root_dir, dir, 'exemplars')
206
214
  end
207
215
  array
208
216
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "object-daddy"
8
- s.version = "1.1.1"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rick Bradley", "Yossef Mendelssohn", "Jeremy Holland"]
12
- s.date = "2013-06-16"
12
+ s.date = "2013-06-30"
13
13
  s.description = "Object Daddy is a library (as well as a Ruby on Rails plugin) designed to assist in automating testing of large collections of objects, especially webs of ActiveRecord models. It is a descendent of the \"Object Mother\" pattern for creating objects for testing, and is related to the concept of an \"object exemplar\" or stereotype."
14
14
  s.email = ["blogicx@rickbradley.com", "ymendel@pobox.com", "jeremy@jeremypholland.com"]
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object-daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-06-16 00:00:00.000000000 Z
14
+ date: 2013-06-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -219,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  segments:
221
221
  - 0
222
- hash: -4577695941973992305
222
+ hash: 3406508294409145889
223
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  none: false
225
225
  requirements: