/bdd

Given/When/Then/And/But output to RSpec and Minitest

Primary LanguageRubyMIT LicenseMIT

Bdd

Bdd is a User Story Framework. Add Acceptance Criteria documentation directly on your Ruby Tests.

Status

Is It Working? Is It Tested? Code Quality # of Downloads Get Involved!
Master Build Status Code Climate Code Climate Downloads GitHub Issues

Compatibility

Ruby 2.0 through 2.7

Pitch

This gem provides the same benefits as gem Cucumber, and it's easier to use in projects.

Works with all ruby test frameworks (RSpec and Minitest).
Works with all test types (Capybara, units, features, etc).


1. Take your User Stories.

2. Write them as unobtrusive commentary in your test code.

3. Run your tests.

4. You'll see all your User Stories neatly organized in the output.

5. If your code breaks, that line will be highlighted in red.

Read more about User Stories on Wikipedia.

Example

1. BEFORE

Before

2. AFTER

After

3. RUN TESTS

Run Tests

4. CHECK OUTPUT

Check Output

Installation

Installation For RSpec

# Gemfile

group :development, :test do
  gem 'rspec'
  gem 'rspec-rails' # if you are using Rails
  gem 'bdd'
end
# spec/spec_helper.rb
require 'bdd'

Bdd.configure do |config|
  config.framework :rspec
  config.reporters :output, :yaml
  config.language %w[Given], %w[When Then], %w[And But]

  # Optionally, add other languages:
  # config.language pre_conditions, post_conditions, conjunctions
  # config.language %w[Dado], %w[Quando Entao], %w[E Mas] # Portuguese
  # config.language %w[Dato], %w[Cuando Entonces], %w[Y Mas] # Spanish
  # config.language %w[Zakładając], %w[Jeśli To], %w[Także Ale] # Polish
end

Installation For Minitest

# Gemfile

group :development, :test do
  gem 'minitest'
  gem 'minitest-rails' # if you are using Rails
  gem 'bdd'
end
# test/test_helper.rb
require 'bdd'

Bdd.configure do |config|
  config.framework :minitest
  config.reporters :output, :yaml
  config.language %w[Given], %w[When Then], %w[And But]

  # Optionally, add other languages:
  # config.language pre_conditions, post_conditions, conjunctions
  # config.language %w[Dado], %w[Quando Entao], %w[E Mas] # Portuguese
  # config.language %w[Dato], %w[Cuando Entonces], %w[Y Mas] # Spanish
  # config.language %w[Zakładając], %w[Jeśli To], %w[Także Ale] # Polish
end

Authors & Contributions

Contributing

  1. Fork it ( https://github.com/thejamespinto/bdd/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Documentation

Chart

  • Frameworks
    • RSpec
    • Minitest
  • Reporters
    • Output
    • YAML
    • HTML