Ad
  • Custom User Avatar

    yes, I totally agree with your second comment, but not the first ;) I've added additional test for this case:

    it 'does not expand coupon for other products' do
        order = { signs_of_four: 5, adventures: 10 }
        coupon = { value: -9, product: :signs_of_four }
    
        Test.assert_equals( apply_coupon(coupon, order), 10, "should return 10 for order #{order} and coupon #{coupon}" )
    end
    

    My solution to this kata already passes this test case :)

  • Custom User Avatar

    you're right, examples changed, thx

  • Custom User Avatar

    I am not sure why you suggest that behavior. If I go to the shop and give them coupon with value 10$ I can get book with price 7$ for free. You 'loose' 3$ but it is still valid coupon. I'm pretty sure this works in Poland that way ;)

    In your example 5 is the valid value for this order, so the test with 15 would be invalid ;)

  • Custom User Avatar

    just to mark resolved

  • Custom User Avatar

    I think this doesn't matter for kata, but few comments ago I had idea that empty array can be for empty pockets, and nil can be for 'no pockets' in real life example ;)

  • Custom User Avatar

    from docs "Kata Approval":

    After a kata has received 5 approval votes from the community, 
    fixed any issues, and reached a consensus on it's ranking...
    

    how can I ask someone to come back and mark issue resolved? Does the issue expire? Can you block any beta kata now in this way?

  • Custom User Avatar

    Strange, I've added your debug line and have valid values, really don't know what can I do with this

    Description updated with your suggestions although I don't fully aggree with your points ;) In real life clients tend to write/speak short description of their problem (often badly) and after some discussion I write tests to match desired behaviour of the app ;)

  • Custom User Avatar

    Weird, there is no tests with values you provided, in first example value for aventures is 4 not 3.6, in second: 25

    Typo fixed.

    I don't think that description isn't sufficient, there is warning about valid coupons and everybody (should) knows that you cannot have negative values for orders ;) You are given this feedback in the tests too

    And finally there is no tests with problematic results for example 1.33333, I wanted it to be simple, 2 decimal places are standard for order/currency calculations.

  • Custom User Avatar

    thank you for this hint, I didn't see this in the docs, fixed

    edit: omg, I'm so blind ;)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    lot of fun with this kata, lot of nice solutions to read, thanks

  • Custom User Avatar

    I marked it clever but I think it's 'too hardcoded'. It looks more like picking some values and merging them than calculating.

  • Custom User Avatar

    'and' should not be used in logical comparisions, it should be used only in flow logic, for example in ruby on rails controllers you often see something like:

    def foo
      if bar
        redirect_to :root and return
      end
      
      # do semething else...
    end
    

    yes, using 'and' often gives valid results but it's bad practice because the 'and' operation has lower precedence than '&&' and you asking for strange bugs in code

  • Custom User Avatar

    I forgot that there is no real rspec ;) descriptions added

  • Custom User Avatar

    I wanted it to be like some additional kind of puzzle with this kata, but you are right, this can be confusing, starter fixed