Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

version 0.2.3. handles more column types, more info in readme

  • Loading branch information...
commit 9b6dfaa2fcc8146ad3a51d34c06d285436af1d79 1 parent eff0b82
@garysweaver authored
Showing with 20 additions and 9 deletions.
  1. +12 −0 README.md
  2. +7 −8 lib/stepford/common.rb
  3. +1 −1  lib/stepford/version.rb
View
12 README.md
@@ -71,6 +71,18 @@ If you are using STI, you'll need to manually fix the value that goes into the `
Tested with postgreSQL 9.x only.
+If you use stepford to create factories for existing tests and the tests fail with:
+
+ ActiveRecord::StatementInvalid:
+ PG::Error: ERROR: null value in column "something_id" violates not-null constraint
+
+or maybe:
+
+ ActiveRecord::RecordInvalid:
+ Validation failed: Item The item is required., Pricer The pricer is required., Purchased by A purchaser is required.
+
+you might either need to modify those factories to set associations that are required or specify `--associations` in stepford to attempt generate them.
+
If you specify `--associations`, you might get circular associations and could easily end up with:
SystemStackError:
View
15 lib/stepford/common.rb
@@ -2,7 +2,7 @@ module Stepford
class Common
def self.value_for(column)
case column.type
- when :string
+ when :string, :text
if column.default.nil?
result = "Test #{column.name.titleize}"
column.limit && column.limit < result.size ? (column.limit >= 0 ? "'#{'a' * column.limit}'" : 'nil') : "'#{result}'"
@@ -11,22 +11,21 @@ def self.value_for(column)
end
when :integer
column.default.nil? ? (column.limit ? column.limit.to_s : '123') : column.default.to_s
- when :decimal
+ when :decimal, :float
column.default.nil? ? (column.limit ? column.limit.to_s : '1.23') : column.default.to_s
- when :datetime
- '{ 2.weeks.ago }'
- when :timestamp
+ when :date, :datetime, :timestamp
'{ 2.weeks.ago }'
when :binary
column.default.nil? ? (column.limit ? column.limit.to_s : '0b010101') : column.default.to_s
when :boolean
column.default.nil? ? 'true' : column.default.to_s
when :xml
- '<test>Test #{column_name.titleize}</test>'
+ column.default.nil? ? '<test>Test #{column_name.titleize}</test>' : column.default.to_s
when :ts_vector
- 'nil'
+ column.default.nil? ? 'nil' : column.default.to_s
else
- 'nil'
+ puts "Stepford does not know how to handle type #{column.type.to_sym}"
+ column.default.nil? ? 'nil' : column.default.to_s
end
end
end
View
2  lib/stepford/version.rb
@@ -1,3 +1,3 @@
module Stepford
- VERSION = '0.2.2'
+ VERSION = '0.2.3'
end
Please sign in to comment.
Something went wrong with that request. Please try again.