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

Alora Riley #13

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

Alora Riley #13

wants to merge 28 commits into from

Conversation

aloraalee
Copy link

Did not pass iteration 2.


def initialize(item_info)
@name = item_info[:name]
@price = item_info[:price]
Copy link
Contributor

Choose a reason for hiding this comment

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

Price should be converted to float data type per the interaction pattern

end

it 'can stock items' do
@vendor.stock(@item1, 30)
Copy link
Contributor

Choose a reason for hiding this comment

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

A good test here would be to stock the same items a few times, and check that the quantity of your item is accumulating

lib/vendor.rb Outdated
end

def revenue_item1
item1 = Item.new({name: 'Peach', price: "$0.75"})
Copy link
Contributor

Choose a reason for hiding this comment

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

item1 is hardcoded here, so this helper method isn't dynamic / only works for this type of item.

lib/vendor.rb Outdated
end

def potential_revenue
revenue_item1
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider taking your inventory hash and the .sum enumerable to take all the items (and their respective prices) and multiply by their quantity


it 'can list vendors that sell' do

expect(@market.vendors_that_sell(@item1)).to match_array([@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.

.to match_array - nice assertion here!

expect(@vendor.inventory).to eq({@item1 => 30})
end

it 'can calculate potential revenue' do
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is the right idea!! Good to see you doing some TDD. Were you able to figure out the potential_revenue method?

lib/vendor.rb Outdated
def revenue_item1
item1 = Item.new({name: 'Peach', price: "$0.75"})
price = item1.price
vendor1 = Vendor.new("Rocky Mountain Fresh")
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldnt be creating new class instances within the class definition of the class. The vendor you instantiate in your tests will have the same and functionality defined in this file.

Comment on lines +15 to +25
it 'can be initialized' do
expect(@market).to be_instance_of(Market)
end

it 'has a name' do
expect(@market.name).to eq("South Pearl Street Farmers Market")
end

it 'can list vendors' do
expect(@market.vendors).to eq([])
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests that describe what happens in the initialize function can be grouped together, which might save some time on the IC

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