-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Alora Riley #13
Conversation
|
||
def initialize(item_info) | ||
@name = item_info[:name] | ||
@price = item_info[:price] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"}) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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
Did not pass iteration 2.