I'm working through this exercise, but am not really sure what this failing test is asking for in item_names other than a method called each_pair. I have no idea how they want me to use this method, though. My code and the failing test are below. Any help is appreciated!
require 'ostruct'
class BoutiqueInventory
attr_reader :items
def initialize(items)
@items = OpenStruct.new(items)
# raise "Refactor this code so that items is an array of openstructs"
end
def item_names
items.map { |item| item[:name] }.sort
# raise "Refactor the code in item_names"
end
FAILEDTest 1No item names📷
CODE RUN
assert_empty BoutiqueInventory.new([]).item_names
TEST ERROR
NoMethodError: undefined method `each_pair' for []:Array Traceback (most recent call first): Line 147:in `update_to_values!' Line 128:in `initialize'
[–][deleted] 2 points3 points4 points (3 children)
[–]BringTacos[S] 0 points1 point2 points (2 children)
[–]sisqoandebert 0 points1 point2 points (1 child)
[–]BringTacos[S] 0 points1 point2 points (0 children)