class ActiveCucumber::ActiveRecordBuilder

Creates ActiveRecord entries with data from given Cucumber tables.

Public Class Methods

new(activerecord_class, context) click to toggle source
# File lib/active_cucumber/active_record_builder.rb, line 6
def initialize activerecord_class, context
  @clazz = activerecord_class
  @creator_class = creator_class
  @context = context
end

Public Instance Methods

attributes_for(attributes) click to toggle source
# File lib/active_cucumber/active_record_builder.rb, line 13
def attributes_for attributes
  @creator_class.new(attributes, @context).factorygirl_attributes
end
create_many(table) click to toggle source

Creates all entries in the given horizontal table hash

# File lib/active_cucumber/active_record_builder.rb, line 19
def create_many table
  table.map do |row|
    create_record row
  end
end
create_record(attributes) click to toggle source

Creates a new record with the given attributes in the database

# File lib/active_cucumber/active_record_builder.rb, line 27
def create_record attributes
  creator = @creator_class.new attributes, @context
  FactoryGirl.create @clazz.name.underscore.to_sym, creator.factorygirl_attributes
end

Private Instance Methods

creator_class() click to toggle source

Returns the Cucumberator subclass to be used by this Cucumparer instance

# File lib/active_cucumber/active_record_builder.rb, line 36
def creator_class
  creator_class_name.constantize
rescue NameError
  Creator
end
creator_class_name() click to toggle source

Returns the name of the Cucumberator subclass to be used by this Cucumparer instance.

# File lib/active_cucumber/active_record_builder.rb, line 44
def creator_class_name
  "#{@clazz.name}Creator"
end