For faster navigation, this Iframe is preloading the Wikiwand page for RSpec.

RSpec

Матеріал з Вікіпедії — вільної енциклопедії.

RSpec
ТипBDD каркас / інструмент для тестування
Перший випуск18 травня 2007; 17 років тому (2007-05-18)
Стабільний випуск3.5.0 (1 липня 2016; 8 років тому (2016-07-01))
Платформакросплатформне
Операційна системакросплатформова програма
Мова програмуванняRuby[1]
ЛіцензіяMIT
Репозиторійgithub.com/rspec/rspec-rails
Вебсайтrspec.info

RSpecпредметно-орієнтований інструмент для тестування коду на Ruby, написаний на Ruby. BDD каркас широкого використання.

Основна ідея інструменту — керована тестами розробка, за якої спочатку пишуться тести, а після цього — код програми.

Використання

[ред. | ред. код]

RSpec надає предметно-орієнтовану мову для опису поведінки об'єктів. Ключові слова, які використовуються в RSpec, схожі на ті, які використовуються в інших мовах.

Кожна система тестування працює в наступному потоці: є певний контекст, де відбуваються певні події, описується результат, що очікується. Методи describe(), context() та it() є основноми при написанні коду за допомогою RSpec.

describe()

Метод describe() використовується для опису класів, методів або групи прикладів.

describe 'Some spec' do
...
end
context()

Блок context() призначений для класу чи методу, що можна згрупувати за контекстом. Міститься всередині describe().

describe 'Some spec' do
    context 'Some context within describe' do
        ....
    end
end
it()

Метод для опису прикладу в контексті. Міститься всередині context() або describe(), якщо перший відсутній.

describe 'Some spec' do
    context 'Some context within describe' do
        it 'Some example within context' do
            puts 'First test is here.'
        end
    end
end

Джерела

[ред. | ред. код]
  1. The rspec Open Source Project on Open Hub: Languages Page — 2006.
{{bottomLinkPreText}} {{bottomLinkText}}
RSpec
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?