Make `UnexpectedNilError` un-rescueable from tests

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
ruby
領域
testing

調査の方向性

まず UnexpectedNilError と not_nil! の実装を見つけ、次にプロジェクトが minitest または RSpec をどのように呼び出しているかを調べます。テストランナーをクラッシュさせずに、単純な rescue => e がこのエラーを隠すのをテストで防ぐ方法を特定します。minitest と RSpec が引き続き実行され、通常のテストコードではエラーを捕捉できない状態が保たれれば完了です。

索引モデルが issue の本文から書いたものです。

説明

It currently inherits from Exception, so that a bare rescue => e doesn't unintentionally rescue it. We've already run into a real-world case where that proved useful, where a fork of the not_nil! implementation made it derive from StandardError, which indeed hid a test failure (only detected because we switched that copy of the code to use Type Toolkit).

To make it truly uncatchable, we can do something like throw Object.new. In a production app, this would crash your Rails app with UncaughtThrowError, so we'd have to limit it to tests. But we also don't want to crash minitest/RSpec, so we'd need to wrap the test runner in a catch call. We would need some kind of secret-ish tag to throw, that only the test runner can catch.

主要言語
Ruby
スター
3
フォーク
5
平均マージ
8日 23時間
マージ済み PR(30日)
8

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Shopify/type_toolkit のほかの issue

Shopify/type_toolkit の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

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

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