Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IC #5 Montana Pfeifer #12

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

Montana-Pfeifer
Copy link

finished up to end of iteration 3

expect(@vendor.check_stock(@item1)).to eq(0)
end

it 'stocks items in inventory' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are failing - we're getting an object back that looks like +#<Item:0x00007f9a182d3de0 @name="Peach", @price=0.75> => {:quantity=>30} - I'd like to see something more like <Item:0x00007f7f2c2cfb48 @name="Tomato", @price=0.5> => 10. What you did here works but doesnt quite follow the interaction pattern.

end

def stock(item, quantity)
@inventory[item][:quantity] += quantity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was expecting something a little more like this here @inventory[item] += quantity


def initialize(details)
@name = details[:name]
@price = details[:price].delete('$').to_f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way to clean the string input, and convert it to the correct data type.

end

def sorted_item_list
@vendors.flat_map { |vendor| vendor.inventory.keys.map(&:name) }.uniq.sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These one liners are nice !!

@vendors.flat_map { |vendor| vendor.inventory.keys.map(&:name) }.uniq.sort
end

def total_inventory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a simpler solution here! Might be worth asking ChatGPT :)

@market.add_vendor(@vendor3)

expected = {
@item1 => { quantity: 100, vendors: [@vendor1, @vendor3] },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the interaction pattern, the items should looks like

pry(main)> vendor.inventory
#=> {#<Item:0x007f9c56740d48...> => 55, #<Item:0x007f9c565c0ce8...> => 12}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where the item object is the key, and the quantity is the value.

end

it "calculates potential_revenue" do
expect(@vendor1.potential_revenue).to eq(29.75)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you are testing different vendors (scenarios) and testing how the outputs differ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants