Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Interactions between Lolex, Timecop and the Cache in HyperSpec

オープン
#452 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hyperstack-org/hyperstack のほかの issue

hyperstack-org/hyperstack の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。