Допустим, у меня есть несколько тестов:
spec/code_spec.rb
:
require "rails_helper"
RSpec.describe Code do
xit { Code.evaluate("Twitter.search") }
xit { Code.evaluate("Slack.send") }
xit { Code.evaluate("Twitter.send") }
end
Я получил:
~/s/d/code> rspec spec/code_spec.rb
Randomized with seed 54828
Code
example at ./spec/code_spec.rb:5 (PENDING: Temporarily skipped with xit)
example at ./spec/code_spec.rb:6 (PENDING: Temporarily skipped with xit)
example at ./spec/code_spec.rb:4 (PENDING: Temporarily skipped with xit)
Pending: (Failures listed here are expected and do not affect your suite's status)
1) Code
# Temporarily skipped with xit
# ./spec/code_spec.rb:5
2) Code
# Temporarily skipped with xit
# ./spec/code_spec.rb:6
3) Code
# Temporarily skipped with xit
# ./spec/code_spec.rb:4
Finished in 0.00251 seconds (files took 3.32 seconds to load)
3 examples, 0 failures, 3 pending
Randomized with seed 54828
Мне бы хотелось, чтобы rspec выполнял тесты и терпел неудачу, если они пройдены, в идеале сообщая мне, что мне нужно их отменить.
Является ли это возможным?
🤔 А знаете ли вы, что...
Ruby предоставляет инструменты для создания RESTful веб-сервисов.
Вы можете добавить pending: 'pending reason'
к описанию теста
все описано здесьhttps://www.joshmcarthur.com/til/2019/05/27/pending-block-examples-with-rspec.html
этот тест будет запущен rspec, но не завершится провалом всего набора тестов
it 'adds 1 + 1 and equals 3', pending: true do
expect(1 + 1).to eq 3
end
но этот тест завершится неудачно, потому что ошибка не возникла
it 'adds 1 + 1 and equals 2', pending: true do
expect(1 + 1).to eq 2
end