moonmaster9000-dupe 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dupe/dupe.rb +4 -4
- data/lib/dupe/record.rb +9 -1
- metadata +1 -1
data/lib/dupe/dupe.rb
CHANGED
@@ -74,7 +74,7 @@ class Dupe
|
|
74
74
|
# will ask Dupe to mock ActiveResource responses to find(:all) and find(:id) with the data
|
75
75
|
# specified in the cucumber hash table immediately following the "Given the following author:" line.
|
76
76
|
# Since we didn't specify a 'bio' value in our cucumber hash table, Dupe will give it the
|
77
|
-
# default value '
|
77
|
+
# default value 'Lorem ipsum delor.'. Also, it will transform the 'date_of_birth' value we provided in the hash
|
78
78
|
# table into a time object.
|
79
79
|
#
|
80
80
|
# Similarly, for the :book cucumber hash table, Dupe will transform the author name we provided
|
@@ -87,7 +87,7 @@ class Dupe
|
|
87
87
|
# <author>
|
88
88
|
# <id type="integer">1</id>
|
89
89
|
# <name>Arthur C. Clarke</name>
|
90
|
-
# <bio>
|
90
|
+
# <bio>Lorem ipsum delor.</bio>
|
91
91
|
# <date_of_birth>1917-12-16T00:00:00Z</date_of_birth>
|
92
92
|
# </author>
|
93
93
|
#
|
@@ -99,7 +99,7 @@ class Dupe
|
|
99
99
|
# <author>
|
100
100
|
# <id type="integer">1</id>
|
101
101
|
# <name>Arthur C. Clarke</name>
|
102
|
-
# <bio>
|
102
|
+
# <bio>Lorem ipsum delor.</bio>
|
103
103
|
# <date_of_birth>1917-12-16T00:00:00Z</date_of_birth>
|
104
104
|
# </author>
|
105
105
|
# </book>
|
@@ -181,7 +181,7 @@ class Dupe
|
|
181
181
|
# Dupe.define :author {|author| author.name('default')}
|
182
182
|
#
|
183
183
|
#
|
184
|
-
#
|
184
|
+
# then stub would have generated 20 author records like:
|
185
185
|
#
|
186
186
|
# {:name => 'default', :id => 1}
|
187
187
|
# ....
|
data/lib/dupe/record.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
class Dupe
|
2
2
|
class Record #:nodoc:
|
3
3
|
def initialize(hash)
|
4
|
-
@attributes = hash.merge(hash)
|
4
|
+
@attributes = hash.merge(hash) do |k,v|
|
5
|
+
if v.is_a?(Hash)
|
6
|
+
Record.new(v)
|
7
|
+
elsif v.is_a?(Array)
|
8
|
+
v.map {|r| Record.new(r)}
|
9
|
+
else
|
10
|
+
v
|
11
|
+
end
|
12
|
+
end
|
5
13
|
end
|
6
14
|
|
7
15
|
def method_missing(method_name, *args, &block)
|