Extension:Expect/ru

From Linux Web Expert

Справка по расширениям MediaWiki
Expect
Статус релиза: бета
File:Keepcalms.png
Реализация API
Описание Provides extended assertions for Scribunto.
Автор(ы)
  • John Erling Blad (Jebladtalk)
Политика совместимости Master maintains backward compatibility.
MediaWiki
Изменения в БД Нет
Лицензия GNU General Public License 2.0 или позднее
Скачать
README, LDoc
Ежеквартальные загрузки Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Использование общедоступными вики Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Переведите расширение Expect

Expect provides an extended framework for assertions.

It is based upon compute graphs that are predefined before being used for extensive checks.

Установка

Expect depends on modules from the Scribunto extension.

  • <translate> Download and place the file(s) in a directory called <tvar name=name>Expect/ru</tvar> in your <tvar name=ext>extensions/</tvar> folder.</translate>
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'Expect/ru' );
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Использование

The workflow is to define a graph, and then provide arguments to that graph. The definition is done once, but the graph can be reused several times.

-- Load the lib
local expect = require 'expect'

-- Create a few compute graphs
local expectString = expect:create():asType():toBeEqual( 'string' )
local expectNoColon = expect:create():toBeUMatch( '^[^:]*$' )

-- Create an exported hash
local p = {}

-- Add a function
function p.helloWorld( name )
	-- Call the compute graphs
	expectString( name )
	expectNoColon( name )

	-- Should be safe to do whatever now
	return mw.ustring.format( 'Hi there %s!', name )
end

-- Return the exported hash
return p

For further help, see the generated LDoc documentation.

Разработка

For recreating the Vagrant-based development environment, see Expect: Topics/Vagrant.

См. также