Extension:Expect/ru

From mediawiki.org
This page is a translated version of the page Extension:Expect and the translation is 31% complete.
Справка по расширениям MediaWiki
Expect
Статус релиза: бета
Реализация API
Описание Provides extended assertions for Scribunto.
Автор(ы)
  • John Erling Blad (Jebladобсуждение)
Последняя версия 0.1.0
Политика совместимости Master maintains backward compatibility.
MediaWiki >= 1.33
Изменения в БД Нет
Composer jeblad/expect
Лицензия GNU General Public License 2.0 или позднее
Скачать
README, LDoc
Переведите расширение 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.

  • Скачайте и распакуйте файл(ы) в папку с названием Expect в вашей папке extensions/.
  • Добавьте следующий код в конце вашего файла LocalSettings.php :
    wfLoadExtension( 'Expect' );
    
  • Yes Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.

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

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.

См. также