Skip to content

Instantly share code, notes, and snippets.

View moiristo's full-sized avatar
💭
Monkey see monkey do

Reinier de Lange moiristo

💭
Monkey see monkey do
View GitHub Profile
@moiristo
moiristo / assert_differences
Created November 11, 2010 13:07
Test helper method to perform multiple assert_difference calls easily.
# Example
assert_differences 'Initiative.count' => 1, 'Role.count' => -1, 'Phase.count' => 0 do
@initiative.to_template!
end
def assert_differences(collection = {}, &block)
yield and return if collection.empty?
collection.shift.tap do |diff|
assert_differences(collection){ assert_difference(diff.first, diff.last, &block) }
def gregorian_date?(date)
return false if date.nil?
(date.month == 2 and date.day == 29) ? Date.gregorian_leap?(date.year) : true
end