エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント3件
- 注目コメント
- 新着コメント
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
[ruby][rails]テストの時にTime.nowで好きな時間を使えるようにするMock - よしだメモ
class AgentTest < Test::Unit::TestCase def test_notice Time.class_eval do class << self alias_met... class AgentTest < Test::Unit::TestCase def test_notice Time.class_eval do class << self alias_method :real_now, :now end def self.mock_now @current_time end def self.mock!(time) class << Time; alias_method :now, :mock_now; end @current_time = time yield class << Time; alias_method :now, :real_now; end end end Time.mock!(Time.parse("2007-10-10 11:11:11")) do assert_equal "2007-10-10", Agent.notice[
2014/04/01 リンク