Interactions between Lolex, Timecop and the Cache in HyperSpec
還沒有人認領這個 Issue。
評估
研究方向
先定位 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
hyperstack-org/hyperstack 的其他 Issue
-
enhancement needs doc
難度 2/5 1-3 小時 新手友好度 68/100
hyperstack-org/hyperstack#359 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
hyperstack-org/hyperstack#267 ·
-
難度 5/5 一週以上 新手友好度 25/100
hyperstack-org/hyperstack#457 ·
-
難度 3/5 1-2 天 新手友好度 35/100
hyperstack-org/hyperstack#456 ·
-
難度 5/5 一週以上 新手友好度 15/100
hyperstack-org/hyperstack#455 · 2 則留言 ·
查看 hyperstack-org/hyperstack 的全部 Issue
相似的 Issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 70/100
georgestephanis/p2026#40 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·