The library extends the DSL of RSpec with the following methods:
-
background
, -
given
, -
feature
, -
scenario
, and -
shared_scenarios
.
Installation
In Gemfile
:
gem 'rspec-bdd'
Usage
Before:
RSpec.describe 'Awesome feature' do
before do
expect(true).to be true
end
let(:truth) { true }
let!(:lie) { false }
it 'Superb scenario' do
expect(truth).to be true
end
xit 'Bad scenario' do
expect(truth).to be false
end
shared_examples 'Comprehensive scenarios' do
it 'Handsome scenario' do
expect(lie).to be false
end
end
include_examples 'Comprehensive scenarios'
end
After:
require 'rspec/bdd'
RSpec.feature 'Awesome feature' do
background do
expect(true).to be true
end
given(:truth) { true }
given!(:lie) { false }
scenario 'Superb scenario' do
expect(truth).to be true
end
xscenario 'Bad scenario' do
expect(truth).to be false
end
shared_scenarios 'Comprehensive scenarios' do
scenario 'Handsome scenario' do
expect(lie).to be false
end
end
include_scenarios 'Comprehensive scenarios'
end
Acknowledgments
The library is inspired by Capybara.