midiskirt 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/midiskirt.rb +3 -1
- data/lib/midiskirt/version.rb +1 -1
- data/test/test_helper.rb +12 -0
- data/test/unit/midiskirt_test.rb +8 -2
- metadata +7 -7
data/lib/midiskirt.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support/inflector'
|
2
2
|
require 'active_support/core_ext/hash'
|
3
|
+
require 'active_support/core_ext/object/duplicable'
|
3
4
|
|
4
5
|
# Factory girl, relaxed.
|
5
6
|
#
|
@@ -70,7 +71,8 @@ class Midiskirt
|
|
70
71
|
|
71
72
|
klass.new do |record|
|
72
73
|
attributes.each do |name, value|
|
73
|
-
|
74
|
+
value = value.kind_of?(Proc) ? value.call(record) : value
|
75
|
+
record.send(:"#{name}=", value.duplicable? ? value.dup : value)
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
data/lib/midiskirt/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -23,6 +23,10 @@ class Post < Mock
|
|
23
23
|
attr_accessor :user
|
24
24
|
end
|
25
25
|
|
26
|
+
class Unbeatable < Mock
|
27
|
+
attr_accessor :locked, :state, :email, :age, :male
|
28
|
+
end
|
29
|
+
|
26
30
|
Midiskirt.define :admin, :parent => :user do |f|
|
27
31
|
f.login "admin"
|
28
32
|
end
|
@@ -45,4 +49,12 @@ DefaultSettings = {
|
|
45
49
|
Midiskirt.define :guest, :class => :user do |f|
|
46
50
|
f.login "guest"
|
47
51
|
f.settings DefaultSettings
|
52
|
+
end
|
53
|
+
|
54
|
+
Midiskirt.define :unbeatable do |f|
|
55
|
+
f.locked false
|
56
|
+
f.state :enabled
|
57
|
+
f.email nil
|
58
|
+
f.age 19
|
59
|
+
f.male true
|
48
60
|
end
|
data/test/unit/midiskirt_test.rb
CHANGED
@@ -87,14 +87,14 @@ class MidiskirtTest < Test::Unit::TestCase
|
|
87
87
|
|
88
88
|
def test_objects_should_not_corrupt_attribute_templates
|
89
89
|
factories = Midiskirt.instance_variable_get(:@factories)
|
90
|
-
|
90
|
+
assert_not_same DefaultSettings, factories["guest"].__attrs__["settings"]
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_factories_should_not_corrupt_attribute_templates
|
94
94
|
alice = Factory.build :guest
|
95
95
|
bob = Factory.build :guest
|
96
96
|
|
97
|
-
|
97
|
+
assert_not_same DefaultSettings, alice.settings
|
98
98
|
|
99
99
|
alice.settings["eyes"] = "brown"
|
100
100
|
|
@@ -104,4 +104,10 @@ class MidiskirtTest < Test::Unit::TestCase
|
|
104
104
|
def test_should_sequence_without_database
|
105
105
|
assert_not_equal Factory.build(:user).login, Factory.build(:user).login
|
106
106
|
end
|
107
|
+
|
108
|
+
def test_should_not_dup_singletons
|
109
|
+
assert_nothing_raised(TypeError) {
|
110
|
+
Factory(:unbeatable)
|
111
|
+
}
|
112
|
+
end
|
107
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midiskirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-03-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
|
-
requirement: &
|
17
|
+
requirement: &70260846686360 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70260846686360
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
|
-
requirement: &
|
28
|
+
requirement: &70260846685920 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70260846685920
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: activesupport
|
39
|
-
requirement: &
|
39
|
+
requirement: &70260846685320 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '2.2'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70260846685320
|
48
48
|
description: Test::Unit begot MiniTest; factory_girl begot Miniskirt, Miniskirt begets
|
49
49
|
Midiskirt
|
50
50
|
email:
|