factory_girl_extensions 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/factory_girl_extensions/module.rb +11 -1
- metadata +20 -9
@@ -29,6 +29,16 @@
|
|
29
29
|
#
|
30
30
|
module FactoryGirlExtensions
|
31
31
|
|
32
|
+
# I was relying on String#underscore being available and it's not always.
|
33
|
+
# Copies this from ActiveSupport.
|
34
|
+
def underscore_string string
|
35
|
+
string.to_s.gsub(/::/, '/').
|
36
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
37
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
38
|
+
tr("-", "_").
|
39
|
+
downcase
|
40
|
+
end
|
41
|
+
|
32
42
|
# This is the actual (private) implementation
|
33
43
|
def self.__method_missing object, name, *args, &block
|
34
44
|
raise '' unless defined? Factory
|
@@ -48,7 +58,7 @@ module FactoryGirlExtensions
|
|
48
58
|
|
49
59
|
if messages
|
50
60
|
# if this is an instance of String/Symbol use this instance as the factory name, else use the class name
|
51
|
-
factory_name = ( object.kind_of?(Symbol) || object.kind_of?(String) ) ? object.to_s.to_sym : object.name.
|
61
|
+
factory_name = ( object.kind_of?(Symbol) || object.kind_of?(String) ) ? object.to_s.to_sym : underscore_string(object.name).to_sym
|
52
62
|
|
53
63
|
factory_method, instance_method = messages
|
54
64
|
instance = Factory.send factory_method, factory_name, *args
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- remi
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-21 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: factory_girl
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">"
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 0
|
30
|
+
- 0
|
23
31
|
version: 0.0.0
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description: helpful extensions for factory_girl
|
26
35
|
email: remi@remitaylor.com
|
27
36
|
executables: []
|
@@ -46,18 +55,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
55
|
requirements:
|
47
56
|
- - ">="
|
48
57
|
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
49
60
|
version: "0"
|
50
|
-
version:
|
51
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
62
|
requirements:
|
53
63
|
- - ">="
|
54
64
|
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
55
67
|
version: "0"
|
56
|
-
version:
|
57
68
|
requirements: []
|
58
69
|
|
59
70
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.6
|
61
72
|
signing_key:
|
62
73
|
specification_version: 3
|
63
74
|
summary: helpful extensions for factory_girl
|