Module: ActiveCucumber

Defined in:
lib/active_cucumber.rb,
lib/active_cucumber/creator.rb,
lib/active_cucumber/cucumparer.rb,
lib/active_cucumber/cucumberator.rb,
lib/active_cucumber/active_record_builder.rb

Overview

The main namespace for this gem

Defined Under Namespace

Classes: ActiveRecordBuilder, Creator, Cucumberator, Cucumparer

Class Method Summary collapse

Class Method Details

.attributes_for(activerecord_class, cucumber_table, context: {}) ⇒ Object

Returns the attributes to create an instance of the given ActiveRecord class that matches the given vertical Cucumber table



11
12
13
14
# File 'lib/active_cucumber.rb', line 11

def self.attributes_for activerecord_class, cucumber_table, context: {}
  builder = ActiveRecordBuilder.new activerecord_class, context
  builder.attributes_for ActiveCucumber.vertical_table(cucumber_table)
end

.create_many(activerecord_class, cucumber_table, context: {}) ⇒ Object

Creates entries of the given ActiveRecord class specified by the given horizontal Cucumber table



19
20
21
22
# File 'lib/active_cucumber.rb', line 19

def self.create_many activerecord_class, cucumber_table, context: {}
  builder = ActiveRecordBuilder.new activerecord_class, context
  builder.create_many ActiveCucumber.horizontal_table(cucumber_table)
end

.create_one(activerecord_class, cucumber_table, context: {}) ⇒ Object

Creates an entry of the given ActiveRecord class specified by the given vertical Cucumber table



27
28
29
30
# File 'lib/active_cucumber.rb', line 27

def self.create_one activerecord_class, cucumber_table, context: {}
  builder = ActiveRecordBuilder.new activerecord_class, context
  builder.create_record ActiveCucumber.vertical_table(cucumber_table)
end

.diff_all!(clazz, cucumber_table, context: {}) ⇒ Object

Verifies that the database table for the given ActiveRecord class matches the given horizontal Cucumber table.

Sorts records by creation date.



37
38
39
40
# File 'lib/active_cucumber.rb', line 37

def self.diff_all! clazz, cucumber_table, context: {}
  cucumparer = Cucumparer.new clazz, cucumber_table, context
  cucumber_table.diff! cucumparer.to_horizontal_table
end

.diff_one!(object, cucumber_table, context: {}) ⇒ Object

Verifies that the given object matches the given vertical Cucumber table



44
45
46
47
# File 'lib/active_cucumber.rb', line 44

def self.diff_one! object, cucumber_table, context: {}
  cucumparer = Cucumparer.new object.class, cucumber_table, context
  cucumber_table.diff! cucumparer.to_vertical_table(object)
end

.horizontal_table(table) ⇒ Object

Returns the given horizontal Cucumber table in standardized format



51
52
53
# File 'lib/active_cucumber.rb', line 51

def self.horizontal_table table
  table.hashes
end

.vertical_table(table) ⇒ Object

Returns the given vertical Cucumber table in standardized format



57
58
59
# File 'lib/active_cucumber.rb', line 57

def self.vertical_table table
  table.rows_hash
end