Brutal

Brutal test suite scaffold generator

A lumberjack brutally cutting a tree.

Build Status Gem Version Inline docs Documentation

Installation

Add this line to your application's Gemfile:

gem 'brutal'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install brutal

Quick Start

Just type brutal in a Ruby project's folder and watch the magic happen.

Usage

The Brutal YAML file handles 4 keys:

  • header (optional): Some code to execute before the test suite.
  • subject (required): The front object of the test suite.
  • variables (required): A hash to decline the subject in to various contexts.
  • challenges (required): An array of methods to apply to each result.

Example

Given this .brutal.yml config file:

---
header: |
  # Some string concatenation unit tests

subject: |
  "Hello" + "%{hello_target}%{punctuation_mark}"

variables:
  :hello_target:
    -
    - ", Bob"

  :punctuation_mark:
    - "!"
    - ...

challenges:
  - "%{actual}.to_s"
  - "%{actual}.length"

The brutal command would generate the following file:

# Some string concatenation unit tests

# ------------------------------------------------------------------------------

actual = "Hello" + "!"

raise unless actual.to_s == "Hello!"
raise unless actual.length == 6

# ------------------------------------------------------------------------------

actual = "Hello" + "..."

raise unless actual.to_s == "Hello..."
raise unless actual.length == 8

# ------------------------------------------------------------------------------

actual = "Hello" + ", Bob!"

raise unless actual.to_s == "Hello, Bob!"
raise unless actual.length == 11

# ------------------------------------------------------------------------------

actual = "Hello" + ", Bob..."

raise unless actual.to_s == "Hello, Bob..."
raise unless actual.length == 13

Integration with Rake

The generated brutal test suite test.rb file can be declared as follows:

Rake::TestTask.new do |t|
  t.pattern = 'test.rb'
end

Contact

Rubies

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fixrb/brutal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the GreatGuardian project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.