Skip to content

Conversation

@Lindseyls
Copy link

Grocery Store

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Response
Why is it useful to put classes inside modules? It is useful because then you can easily call and access the classes within the module by using namespacing ModuleName::ClassName.
What is accomplished with raise ArgumentError? I am able to not just give the user an error when the status is not pending or paid, but also can give them the information on why there is an error or most importantly why the new product was not able to be added to the order.
Why do you think we made the .all & .find methods class methods? Why not instance methods? We made the '.all' and '.find' methods class methods because we are calling on the orders from the class itself. The orders are objects within the class. Therefore, in order to go through each line order in the class in order to find all the orders or specific orders based on the id, we need to call upon the whole class.
Why does it make sense to use inheritance for the online order? It makes sense because Online Order is a class related to the Order class. By using inheritance we were able to inherit methods and use super to invoke behavior from the Order class so that we can write less code.
Did the presence of automated tests change the way you thought about the problem? How? It definitely gave me clear instructions on what code I needed to write in order to make sure they are meant to do what the questions ask for. However, I am still unclear on how to write the most affective tests and look forward to learning more about that and perfecting my tests.

…ch product's price to get the sub total. Then I got the final product total by adin the sub total to the sub total multiply by .075 and rounding to the two decimal places.
…nt that will add the new product if the hash does not have the product name already.
…information to see if I get the same expected results and I did.
…rue correct. I also added the rounding to the sub_total so that the product total is rounded to the second decimal place.
…ile. Next, I will work on pulling the first line of the whole csv file.
…I am learning how to read the csv file and working with the codes that we learned in class.
…a line after I was able to just print the first order.
…rder into a hash. Now I will convert what I did into the array.
…o checked if the data structure you used in Wave 1 will still work for the new requirements and it did.
…the id's were not printing correctly. I went back and fixed the issue and the Order#self.all method is printing the id's correctly.
…roducts based on the id that is called. Also, the method will call nil if the ID called does not find the object.
…gh successfully. I unblocked the Wave 1 test and everything ran through successfully as well.
…m the Order class. I tested out the code using ui to see if it works.
…I tried to folow the same list of tests from Wave 1 test under the describe initialize for order.rb. But, I keep getting errors. I am going to come back to this later.
…lineOrder class. I tested it out using ui and I got the total that I expected. yaay.
…ly if there are products. When there are no products to return nil.
… if the online order status is pending or paid.
….csv from the spec file. Also, the OnlineOrder#self.all method will read each online order into an array separating the parameters. In addition, I updated the online_order_spec.rb file to successfuly run all the tests for describe '#add_product' and describe '#OnlineOrder.all'.
…f I can just go super to call from the Order call because nothing in the code changed for the OnlineOrder class.
…o NilClass so that the tests all successfully passed.
…hen I just did status it said it was not set up... so this is my final commit for my order_spec.rb.
I removed my comments and UI below the code.
I removed my comments and UI at the bottom of the code.
I removed the extra comments. Updated comments for the skipped tests and updated lines 64 and 65.
I removed the extra comments and instructions
@tildeee
Copy link

tildeee commented Feb 26, 2018

Grocery Store

What We're Looking For

Feature Feedback
Baseline
Answered comprehension questions x
Used Git Regularly x
Wave 1
All provided tests pass x
Using the appropriate attr_ for instance variables x
Wave 2
All stubbed tests are implemented fully and pass x
Appropriately parses the product data from CSV file in Order.all x
Used CSV library only in Order.all (not in Order.find) x
Used Order.all to get order list in Order.find x
Wave 3
All stubbed tests are implemented fully and pass x
Used inheritance in the initialize for online order x
Used inheritance for the total method in online order x
Use CSV library only in OnlineOrder.all x
Used all to get order list in find x
Appropriately searches for Customer orders in find_by_customer x, n/a
Additional Notes

Good work overall.

Stylistically the code looks good and functions well.

One small thing about constant variables:
You use the constant variable FILE_NAME to describe the path to the CSV files. However, you should be intentional with the scope that the constant variable gets: in this case, we want FILE_NAME to be within the Order class, and FILE_NAME to be within the OnlineOrder class.

The tests are a little "rough"!

To write effective tests, you should think about the following:

  • What action (method) am I trying to test/verify/validate?
  • What is the expected behavior? What are the expected states?

For instance, you have some tests in the order spec about Order.all, such as the following:

it "Returns accurate information about the last order" do
      order = Grocery::Order.all

      order[99].must_be_kind_of Grocery::Order
    end

You successfully test that the order at index 99 should be an instance of the Order class. But what else can we verify?

It would be great if you could verify that the information about the last order that we know from the CSV (it has an ID of 100, and the products represented by the string "Allspice:64.74;Bran:14.72;UnbleachedFlour:80.59"). You can do things like that with order[99].id.must_equal 100.

I think you're on your way to writing better tests in the future :)

Good job overall!

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