An open API service indexing awesome lists of open source software.

https://github.com/phstc/headshift_test

Headshift_test
https://github.com/phstc/headshift_test

Last synced: 9 months ago
JSON representation

Headshift_test

Awesome Lists containing this project

README

          

== Headshift_test/Pablo Cantero

Here is my code for the Code Kata (https://gist.github.com/5977211c8c3c30b43063) proposed

I wrote the checkout class following your interface

co = Checkout.new(pricing_rules)
co.scan(item)
co.scan(item)
price = co.total

I don't know if I didn't understand. But I'm not totaly agree with co.scan. IMHO I think that the pricing_rules must be calculated in the method total

I wrote this code as simple as I could ;)

== Running this code

rake

Rake command will execute a short questionnaire and after it will execute the entire test suite ;)

== Why I cloned the object in checkout_spec.rb

I cloned the products in checkout_spec.rb

co.scan(@fruit_tea.clone)

To use different references, to don't break my code in this part

if count % 2 == 1
product.price = 0
end

If I use the same reference, it will change all objects price (same reference) to 0