https://github.com/phstc/headshift_test
Headshift_test
https://github.com/phstc/headshift_test
Last synced: 9 months ago
JSON representation
Headshift_test
- Host: GitHub
- URL: https://github.com/phstc/headshift_test
- Owner: phstc
- Created: 2011-04-28T01:03:37.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2011-06-01T23:42:43.000Z (about 15 years ago)
- Last Synced: 2025-03-22T08:48:24.310Z (over 1 year ago)
- Language: Ruby
- Homepage: http://pablocantero.com
- Size: 102 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
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