Permalink
Browse files

Update checker returns a boolean if callback was executed or not.

  • Loading branch information...
1 parent 2fdc3ab commit 9a51053c1d0fe4db66f82c93454b8fd8e6d7e192 @josevalim josevalim committed Dec 12, 2011
@@ -32,6 +32,9 @@ def execute_if_updated
if @last_update_at != current_update_at
@last_update_at = current_update_at
@block.call
+ true
+ else
+ false
end
end
end
@@ -42,19 +42,18 @@ def test_should_not_invoke_the_block_on_first_call_if_it_calculates_last_updated
def test_should_not_invoke_the_block_if_no_file_has_changed
i = 0
- checker = ActiveSupport::FileUpdateChecker.new(args){ i += 1 }
- 5.times { checker.execute_if_updated }
- assert_equal 1, i
+ checker = ActiveSupport::FileUpdateChecker.new(args, true){ i += 1 }
+ 5.times { assert !checker.execute_if_updated }
+ assert_equal 0, i
end
def test_should_invoke_the_block_if_a_file_has_changed
i = 0
- checker = ActiveSupport::FileUpdateChecker.new(args){ i += 1 }
- checker.execute_if_updated
+ checker = ActiveSupport::FileUpdateChecker.new(args, true){ i += 1 }
sleep(1)
FileUtils.touch(FILES)
- checker.execute_if_updated
- assert_equal 2, i
+ assert checker.execute_if_updated
+ assert_equal 1, i
end
end

0 comments on commit 9a51053

Please sign in to comment.