Sha256: 73005198ad0e5502c205bd1a6204f052a45c8e27b35eba32bb040fe882d6b131
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module ActiveCucumber # Creates ActiveRecord entries with data from given Cucumber tables. class ActiveRecordBuilder def initialize activerecord_class, context @clazz = activerecord_class @creator_class = creator_class @context = context end def attributes_for attributes @creator_class.new(attributes, @context).factorygirl_attributes end # Creates all entries in the given horizontal table hash def create_many table table.map do |row| create_record row end end # Creates a new record with the given attributes in the database def create_record attributes creator = @creator_class.new attributes, @context FactoryGirl.create @clazz, creator.factorygirl_attributes end private # Returns the Cucumberator subclass to be used by this Cucumparer instance def creator_class creator_class_name.constantize rescue NameError Creator end # Returns the name of the Cucumberator subclass to be used by this Cucumparer instance. def creator_class_name "#{@clazz.name}Creator" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_cucumber-0.2.1 | lib/active_cucumber/active_record_builder.rb |
active_cucumber-0.2.0 | lib/active_cucumber/active_record_builder.rb |