class RSpec::Rails::Api::EntityConfig
Represents an entity configuration. Basically, entities configuration only have a collection of fields and a method to serialize them for comparison with actual content
Attributes
fields[RW]
Public Class Methods
new(fields)
click to toggle source
# File lib/rspec/rails/api/entity_config.rb, line 14 def initialize(fields) @fields = {} fields.each_key do |name| @fields[name] = FieldConfig.new fields[name] end end
Public Instance Methods
expand_with(entities)
click to toggle source
# File lib/rspec/rails/api/entity_config.rb, line 29 def expand_with(entities) hash = to_h hash.each_pair do |field, config| next unless %i[array object].include? config[:type] attributes = config[:attributes] next unless attributes.is_a? Symbol raise "Entity #{attributes} not found for entity completion." unless entities[attributes] hash[field][:attributes] = entities[attributes].expand_with(entities) end end
to_h()
click to toggle source
# File lib/rspec/rails/api/entity_config.rb, line 21 def to_h out = {} @fields.each_key do |key| out[key] = @fields[key].to_h end out end