Extension:Pickle

From mediawiki.org
This page is a translated version of the page Extension:Pickle and the translation is 46% complete.
MediaWiki 拡張機能マニュアル
Pickle
リリースの状態: 実験的
px
実装 ユーザー インターフェイス, データ抽出, API
説明 Scribunto用の基本的なオンサイトテストフレームワークを提供します。
作者
  • John Erling Blad (Jebladトーク)
最新バージョン 0.1.0
互換性の方針 master は後方互換性を維持しています。
MediaWiki 1.33 - 1.35
データベースの変更 いいえ
Composer jeblad/pickle
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
README, LDoc
ヘルプ Help:Pickle
  • $wgIndicator
  • $wgLogEntry
  • $wgExtractor
  • $wgCategory
  • $wgTAP
  • $wgInvokeSubpage
  • $wgTranslationPath
  • $wgDefaultNamespace
  • $wgRenderTypes
  • $wgObserverID
  • $wgSetup
  • $wgExtractStatus
  • $wgExtractorPath
  • $wgNeglectSubpages
  • $wgTranslationFollows
  • $wgRenderPath
  • $wgRenderStyles
Pickle 拡張機能の翻訳にご協力ください

The Pickle (or Behavior-driven development, BDD, previously Spec) extension is an extension for "spec" style testing for Scribunto . Spec type testing is the same type of unit testing that is done in Rspec, Busted and other similar testing frameworks. PHPといくつかのLuaモジュールとそのローカライゼーションに非常に薄い統合を提供することになります。 実際のコードは有効なLuaのままであり、各種エディタのインテリセンスの定義が欠落していることを除けば、すべての編集ツールが動作します。

The extension is called Pickle because you pick on your code. It is also a play with words; gherkins are used for pickles. Gherkin is also a language for "step" style testing, a kind of acceptance testing, so you might say these kinds of code snippets are pickles.

利用者から見たpickle拡張機能の概要は、Help:Pickle に記載されています。

インストール

PickleはScribunto の拡張機能に依存します。 Vagrantベースの開発環境の再構築については、Pickle: Topics/Vagrantを参照してください。


  • ダウンロードして、ファイルをextensions/フォルダー内のPickleという名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'Pickle' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

使用法

この拡張機能は、暗黙的なスタイルまたは明示的なスタイルのテスト用に設定することができます。 The implicit style piggybacks the installation on the describe() call, but this depends on a functional getfenv() call. The Scribunto extension limits the getfenv() call, and according to Extension:Scribunto/Lua reference manual#Differences from standard Lua it is not quite predictable, thus only the explicit style will work.

The reason for the dependency on getfenv() is that the functions are constructed before the describe() function is called, and thus the calling run-time environment are bound without the global functions. To insert the global functions in the correct run-time environment the describe() call use getfenv(). Without the getfenv() call the correct run-time environment must be present while creating the functions. Thus a call describe() must install the global functions.

Switching between the styles are done by the config { "Setup": "implicit" } or { "Setup": "explicit" }.

If you have a module like "Module:HelloWorld", the ubiquitous and quite pesky example, it will be coded as something like

local p = {}

function p.helloWorld()
	return "Hi there!"
end

return p

Then on a subpage /pickle you would test this like like the following

暗黙の形式
return describe 'Hello world' (function()
	subject .helloWorld()
	it 'says hello' (function()
		expect :toBe("Hi there!");
	end)
end)
明示的な形式
mw.pickle:install()

describe 'Hello world' (function()
	subject .helloWorld()
	it 'says hello' (function()
		expect :toBe("Hi there!");
	end)
end)

return mw.pickle:reports()

暗黙の形式では、最初と最後の行が削除され、return文が新しいコードの終わりに移動されます。

There might be additional changes, like where the tap() call is available, and how many describe() calls that can be made.