Ad
  • Default User Avatar

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

  • Default User Avatar

    Thanks for the quick update! However, your reset_complete! now does the same thing as complete! ;) It doesn't set @complete to nil.

  • Default User Avatar

    Changing entered to enter and responded to respond should do the trick ;)

  • Default User Avatar

    Interesting kata. However, I found the description being confusing. You specify "the block passed in to attr_lazy should only be called, and its value applied to the variable, if the variable is nil." Yet your test cases specify that blocks should not reevaluate even if the block returns nil. What's probably meant and what most people understood is "... if the variable is not defined".

    I also noticed a small mistake in the test case should not call the block if the variable is set manually. You set @complete manually using complete! but you don't call check or complete? afterwards. Therefor the case doesn't test any AttrLazy effects at all. complete_checked_at is always nil.

    Also I suggest adding this test case:

    it 'should not call the block if the variable is set manually to nil' do
      example = LazyTest.new
      example.reset_complete! # sets @complete to nil
      example.complete?
      Test.assert_equals(example.complete_checked_at, nil)
    end
    

    My first solution actually allowed evaluation of the block if the variable was manually defined and set to nil before. All current tests pass but it's probably not the expected behaviour. The suggested test covers this scenario.

  • Default User Avatar

    It's a mistake in the random test data. Check the verbs array in the ruby translation tests cases: verbs.grep(/ed$/) =>["entered", "responded"]. It should only contain verbs not already ending in ed.

  • Default User Avatar

    There are random test failures when input starts with Today I didn't entered or Today I didn't responded (which looks incorrect anyway). Example test: It should work for random inputs too - Expected: "I don't think you didn't entered the fireman today, I think you did entered it!"