RSpec BDD Gem Version Dependency Status Build Status

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.

Contributing

  1. Fork the project.
  2. Create a branch for your feature (git checkout -b awesome-feature).
  3. Implement your feature (vim).
  4. Commit your changes (git commit -am 'Implemented an awesome feature').
  5. Push to the branch (git push origin awesome-feature).
  6. Create a new Pull Request.