Class: CemSpecHelper::ResourceDataSpec::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_spec_helper/resource_data_spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, data) ⇒ Resource

Returns a new instance of Resource.



127
128
129
130
131
132
133
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 127

def initialize(title, data)
  @title = title
  @data = data
  @type = @data['type']
  @no_params = false
  @control_data = load_control_data
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



125
126
127
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 125

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



125
126
127
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 125

def type
  @type
end

Instance Method Details

#controls(include_special: true) ⇒ Object



135
136
137
138
139
140
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 135

def controls(include_special: true)
  ctrls = @no_params ? @control_data : @control_data.keys
  return ctrls if include_special

  ctrls.reject { |c| SPECIAL_CONTROLS.include?(c) }
end

#paramsObject



142
143
144
145
146
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 142

def params
  # rubocop:disable Style/CollectionMethods
  control_data.map { |_, v| v if v.is_a?(Hash) }.flatten.compact.uniq.inject(:merge)
  # rubocop:enable Style/CollectionMethods
end

#verify_no_duplicate_controlsObject



148
149
150
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 148

def verify_no_duplicate_controls
  controls.uniq == controls
end