Module: Fictium::RSpec::Autocomplete::Resource

Defined in:
lib/fictium/rspec/autocomplete/resource.rb

Constant Summary collapse

CONTROLLER_TERMINATION =
/Controller$/.freeze

Class Method Summary collapse

Class Method Details

.name_attributes(resource, controller_name) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/fictium/rspec/autocomplete/resource.rb', line 8

def name_attributes(resource, controller_name)
  resource_path = controller_name.sub(CONTROLLER_TERMINATION, '').underscore
  resource.base_path = "/#{resource_path}"
  path_sections = resource_path.split('/')
  plural = path_sections.last
  resource.name = plural.singularize.humanize(capitalize: false)
  resource.summary = Fictium.configuration.summary_format.call(plural)
end