-
Notifications
You must be signed in to change notification settings - Fork 2k
1st commit working - 2nd commit is half-finished and needs work on finishing takeaway tests for added menu spec. #2219
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| class Menu | ||
|
|
||
| attr_accessor :dishes, :menu | ||
| def initialize | ||
| @dishes = dishes | ||
| end | ||
|
|
||
| def dishes | ||
| dishes = [ | ||
| {name: 'Chicken Tikka Masala', price: 6.50}, | ||
| {name: 'Pilau Rice', price: 2.50}, | ||
| {name: 'Nan Bread', price: 1.95}, | ||
| ] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
| end | ||
|
|
||
| def menu_items | ||
| @menu_items = [] | ||
| end | ||
|
|
||
| def list_of_dishes | ||
| dishes.map{ |item, price| menu_items <<item[:name]} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good :) |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| require_relative 'menu' | ||
|
|
||
| class Takeaway | ||
| attr_reader :menu | ||
|
|
||
| def initialize(menu:) | ||
| @menu = menu | ||
| end | ||
|
|
||
| def display_menu | ||
| menu.list_of_dishes | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| require_relative '../lib/takeaway' | ||
|
|
||
| describe Takeaway do | ||
| subject(:takeaway) { described_class.new(menu: menu) } | ||
|
|
||
| let(:menu) { double(:menu, display: display_menu) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
| let(:menu) { Menu.new } | ||
|
|
||
| context 'Menu' do | ||
| it 'displays a list of dishes' do | ||
| expect(menu.menu_items).to include['Chicken Tikka Masala'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe could've added some more dishes also |
||
| end | ||
| end | ||
| 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.
I feel like this could maybe be attr_reader? instead of accessor.
Should :menu be :menu_items?