Extension:Pickle
This extension is incompatible with MediaWiki 1.42 or any later release! You are advised against using this extension on a live site. MediaWiki developers are invited to pledge their efforts to updating this extension to make it compatible with MediaWiki 1.43 by replacing the {{Incompatible }} template with {{Incompatible |version=1.42|pledge=~~~~}} . |
Pickle Release status: experimental |
|
---|---|
Implementation | User interface, Data extraction, API |
Description | Gir grunnleggjande pickle-testing for Scribunto. |
Author(s) | |
Latest version | 0.1.0 |
Compatibility policy | Master maintains backward compatibility. |
MediaWiki | 1.33 - 1.35 |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | GitHub: Note: README, LDoc |
Help | Help:Pickle |
|
|
Translate the Pickle extension | |
Spec-utvidinga (eller Framferdsdreven utvikling, BDD) er ei utviding for Rspec/Busted-typetesting i Scribunto . Spec type testing is the same type of unit testing that is done in Rspec, Busted and other similar testing frameworks. Den vil tilby eit veldig tynt integrasjonslag mot PHP og nokre få Lua-modular og tilhøyrande lokaliseringar. The actual code is still valid Lua, and all editing tools will work, except for missing definitions for intellisense in the various editors.
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.
Eit oversyn over pickle-utvidinga frå eit brukarperspektiv finst på Help:Pickle .
Installering
Spec avheng av Scribunto -utvidinga. For å attskape det Vagrant-baserte utviklingsmiljøet, sjå Pickle: Topics/Vagrant.
- Download and place the file(s) in a directory called
Pickle
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Pickle' );
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Bruk
The extension can be configured for implicit style or explicit style of tests.
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" }
.
Viss du har ein modul som «Module:HelloWorld», det allestadsnærverande og ganske irriterande dømet, så vil det kodast som noko à la
local p = {}
function p.helloWorld()
return "Hi there!"
end
return p
Deretter, på ei testside ville du teste det på denne måten
- Implicit form
return describe 'Hello world' (function()
subject .helloWorld()
it 'says hello' (function()
expect :toBe("Hi there!");
end)
end)
- Explicit form
mw.pickle:install()
describe 'Hello world' (function()
subject .helloWorld()
it 'says hello' (function()
expect :toBe("Hi there!");
end)
end)
return mw.pickle:reports()
I den endelege versjonen kan nokre liner i byrjinga og slutten verte fjerna.
There might be additional changes, like where the tap()
call is available, and how many describe()
calls that can be made.