Skip to content

Instantly share code, notes, and snippets.

@wteuber
Created May 23, 2013 11:50
Show Gist options
  • Select an option

  • Save wteuber/5635528 to your computer and use it in GitHub Desktop.

Select an option

Save wteuber/5635528 to your computer and use it in GitHub Desktop.
standup note
################# CODE #################
def standup_note
'heute: Standup ' + ((Time.now.day % 2).zero? ? 'gegen den ' : 'im ') + 'Uhrzeigersinn'
end
################# PREP #################
class String
def should_include(part)
raise '...but it does not!' unless self.include?(part)
print '.'
true
end
end
unmock = Time.now.method(:day).to_proc
mock_day = 0; mock = -> {mock_day}
Time.send(:define_method, :day, mock)
################# SPEC #################
standup_note.should_include('heute: Standup')
mock_day = 10
standup_note.should_include('gegen den Uhrzeigersinn')
mock_day = 11
standup_note.should_include('im Uhrzeigersinn')
################# CLEAN #################
Time.send(:define_method, :day, unmock)
class String; undef :should_include; end
################# EXEC #################
standup_note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment