Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Interactions between Lolex, Timecop and the Cache in HyperSpec

未關閉
#452 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
ruby
領域
testing

研究方向

先定位 HyperSpec::Internal::Controller 的 cache_read、cache_write 和 cache_delete 方法,然後檢查 Lolex.evaluate_ruby,以及 Filecache 和 Timecop 在其中如何互動。完成的標準是快取操作使用系統時間,並且在 HyperSpec 未掛載時保留 Lolex 更新,同時不傳送不必要的用戶端通訊。

由索引模型根據 Issue 內容生成。

描述

Hyperspec uses the Filecache gem, which uses Time.now. But if Timecop freezes time in a spec, then Time.now is not returning the system time, and the Filecache does not work. This should be fixable by wrapping calls to the Filecache with the timecop return method (and a block.) But this does not in general work because Hyperspec tries to communicate the "return" to the client, even if the client is not running.

The following series of patches fixes the issue, and can be incorporated into the next point release:

module HyperSpec
  module Internal
    module Controller
      class << self
        # wrap all calls with Timecop.return so the file cache gets the true system time
        def cache_read(key)
          Timecop.return { file_cache.get(key) }
        end

        def cache_write(key, value)
          Timecop.return { file_cache.set(key, value) }
        end

        def cache_delete(key)
          Timecop.return { file_cache.delete(key) }
        rescue StandardError
          nil
        end
      end
    end
  end
end

class Lolex
  # store all lolex updates unless hyper_spec is mounted
  def self.evaluate_ruby(&block)
    if @capybara_page&.instance_variable_get('@hyper_spec_mounted')
      @capybara_page.internal_evaluate_ruby(yield)
    else
      pending_evaluations << block
    end
  end
end
主要語言
JavaScript
星號
538
分支
41
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

hyperstack-org/hyperstack 的其他 Issue

查看 hyperstack-org/hyperstack 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。