stepford 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/lib/stepford/common.rb +7 -8
- data/lib/stepford/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -71,6 +71,18 @@ If you are using STI, you'll need to manually fix the value that goes into the `
|
|
71
71
|
|
72
72
|
Tested with postgreSQL 9.x only.
|
73
73
|
|
74
|
+
If you use stepford to create factories for existing tests and the tests fail with:
|
75
|
+
|
76
|
+
ActiveRecord::StatementInvalid:
|
77
|
+
PG::Error: ERROR: null value in column "something_id" violates not-null constraint
|
78
|
+
|
79
|
+
or maybe:
|
80
|
+
|
81
|
+
ActiveRecord::RecordInvalid:
|
82
|
+
Validation failed: Item The item is required., Pricer The pricer is required., Purchased by A purchaser is required.
|
83
|
+
|
84
|
+
you might either need to modify those factories to set associations that are required or specify `--associations` in stepford to attempt generate them.
|
85
|
+
|
74
86
|
If you specify `--associations`, you might get circular associations and could easily end up with:
|
75
87
|
|
76
88
|
SystemStackError:
|
data/lib/stepford/common.rb
CHANGED
@@ -2,7 +2,7 @@ module Stepford
|
|
2
2
|
class Common
|
3
3
|
def self.value_for(column)
|
4
4
|
case column.type
|
5
|
-
when :string
|
5
|
+
when :string, :text
|
6
6
|
if column.default.nil?
|
7
7
|
result = "Test #{column.name.titleize}"
|
8
8
|
column.limit && column.limit < result.size ? (column.limit >= 0 ? "'#{'a' * column.limit}'" : 'nil') : "'#{result}'"
|
@@ -11,22 +11,21 @@ module Stepford
|
|
11
11
|
end
|
12
12
|
when :integer
|
13
13
|
column.default.nil? ? (column.limit ? column.limit.to_s : '123') : column.default.to_s
|
14
|
-
when :decimal
|
14
|
+
when :decimal, :float
|
15
15
|
column.default.nil? ? (column.limit ? column.limit.to_s : '1.23') : column.default.to_s
|
16
|
-
when :datetime
|
17
|
-
'{ 2.weeks.ago }'
|
18
|
-
when :timestamp
|
16
|
+
when :date, :datetime, :timestamp
|
19
17
|
'{ 2.weeks.ago }'
|
20
18
|
when :binary
|
21
19
|
column.default.nil? ? (column.limit ? column.limit.to_s : '0b010101') : column.default.to_s
|
22
20
|
when :boolean
|
23
21
|
column.default.nil? ? 'true' : column.default.to_s
|
24
22
|
when :xml
|
25
|
-
'<test>Test #{column_name.titleize}</test>'
|
23
|
+
column.default.nil? ? '<test>Test #{column_name.titleize}</test>' : column.default.to_s
|
26
24
|
when :ts_vector
|
27
|
-
'nil'
|
25
|
+
column.default.nil? ? 'nil' : column.default.to_s
|
28
26
|
else
|
29
|
-
|
27
|
+
puts "Stepford does not know how to handle type #{column.type.to_sym}"
|
28
|
+
column.default.nil? ? 'nil' : column.default.to_s
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
data/lib/stepford/version.rb
CHANGED