Permalink
Browse files

Generalize single object with transforms feature

  • Loading branch information...
1 parent 61ba845 commit 27c342581f1c87950abaa360ffff27884c6dd0fb @paulelliott committed Mar 12, 2012
@@ -1,13 +1,5 @@
Feature: Active Record Objects
- Scenario: a single object with transform to apply
- Given the following company:
- | name | Widgets Inc |
- Given the following division:
- | name | Southwest |
- | company | Widgets Inc |
- Then that division should reference that company
-
Scenario: multiple objects with transform to apply
Given the following company:
| name | Widgets Inc |
@@ -0,0 +1,14 @@
+Feature: Single object with transform to apply
+
+ Scenario Outline:
+ Given the following <parent fabricator name>:
+ | string field | Widgets Inc |
+ And the following <child fabricator name>:
+ | <parent field name> | Widgets Inc |
+ Then that <child fabricator name> should reference that <parent fabricator name>
+
+ Scenarios:
+ | parent fabricator name | child fabricator name | parent field name |
+ | parent active record model | child active record model | parent_active_record_model |
+ | parent mongoid document | referenced mongoid document | parent_mongoid_document |
+ | parent sequel model | child sequel model | parent_sequel_model |
@@ -1 +1,5 @@
Fabrication::Transform.define(:company, lambda{|company_name| Company.where(:name => company_name).first })
+
+Fabrication::Transform.define(:parent_active_record_model, lambda{|string_field| ParentActiveRecordModel.find_by_string_field(string_field) })
+Fabrication::Transform.define(:parent_mongoid_document, lambda{|string_field| ParentMongoidDocument.where(string_field: string_field).one })
+Fabrication::Transform.define(:parent_sequel_model, lambda{|string_field| ParentSequelModel.where(string_field: string_field).first })

0 comments on commit 27c3425

Please sign in to comment.