-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Sam Button Takeaway Challenge #2231
base: main
Are you sure you want to change the base?
Conversation
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.
Some really interesting implementation here with quantity. Would love to see some more encapsulation and use of private methods to really clearly define what public interface is that the user can do and what the program does in the background. Think that would help you refine your tests further as well as you don't need to test private methods. And fingers crossed you can figure out your ENV variables as well.
require './docs/menu' | ||
|
||
describe Menu do | ||
it 'responds to Menu class' 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.
Don't think this test is needed. Rspec always initialises the subject to be a new instance of the described class
require './docs/order' | ||
|
||
describe Order do | ||
let(:menu) { Menu.create } |
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.
Interesting why .create and not .new ?
end | ||
|
||
it 'responds to add_to_basket' do | ||
expect(subject).to respond_to :add_to_basket |
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.
Think this is being tested below so could probably be refactored out as well
expect(subject.current_order).to eq(["Guinness"]) | ||
end | ||
|
||
it 'can add multiple dishes at once' 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 is clever I hadn't thought about implementing quantity
subject(:sms) { described_class.new } | ||
|
||
before do | ||
allow(sms).to receive(:sms) |
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.
Much prefer this was of stubbing the SMS method directly rather than trying to stub the client like I did
quantity.times { @current_order << dish } | ||
end | ||
|
||
def calculate_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.
Think some of these methods could be encapsulated into private as the the user doesn't need to calculate the price, the program just needs to do it and the user sees the output
@sent | ||
end | ||
|
||
def sms_confirmation |
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.
Nice idea to have the confirmation message, but again could be in private
|
||
class SMS | ||
|
||
ETA = (Time.now + 3600).strftime("%H:%M") |
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.
Magic number could be defined elsewhere
Sam Button
Please write your full name here to make it easier to find your pull request.
User stories
Please list which user stories you've implemented (delete the ones that don't apply).
README checklist
Does your README contains instructions for
Here is a pill that can help you write a great README!