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

Sam Button Takeaway Challenge #2231

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

Conversation

SamButton12
Copy link

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).

  • User story 1: "I would like to see a list of dishes with prices"
  • User story 2: "I would like to be able to select some number of several available dishes"
  • User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order"
  • User story 4: "I would like to receive a text such as "Thank you! Your order was placed and will be delivered before 18:52" after I have ordered"

README checklist

Does your README contains instructions for

  • [] how to install,
  • [] how to run,
  • [] and how to test your code?

Here is a pill that can help you write a great README!

Copy link

@lukestorey95 lukestorey95 left a 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

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 }

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

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

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)

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

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

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")

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

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.

None yet

2 participants