Socket
Book a DemoInstallSign in
Socket

petitest

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

petitest

0.3.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Petitest

Gem Version Documentation

A minimal solid testing framework for Ruby.

demo

Installation

Add this line to your application's Gemfile:

gem "petitest"

And then execute:

bundle

Or install it yourself as:

gem install petitest

Usage

Create your test file

Define a child class of Petitest::Test with #test_xxx methods.

require "petitest/autorun"

class ExampleTest < Petitest::Test
  def test_addition
    assert { 1 + 1 == 100 }
  end
end

Run it

Run your test file as a Ruby script:

ruby test/example_test.rb
PetitestTest
  #test_one_plus_one_to_be_two


Counts:

  1 tests
  1 passes
  0 failures
  0 skips

Times:

  Started:  2017-03-25T15:29:21.243918+09:00
  Finished: 2017-03-25T15:29:21.244149+09:00
  Total:    0.000231s

If any test failed, exit code 1 is returned, othewise 0.

echo $?
0

Assertions

Petitest provides only one assertion method, #assert.

assert { foo }

If you need more assertions, use plugins like patitest-assertions.

Configuration

backtrace_filters

Mechanism for filter out unnecessary lines from error backtrace. Each element must be able to respond to #=== method.

Petitest.configuration.backtrace_filters = [
  -> (line) { line.start_with?("/path/to/petitest/lib") },
]

color

Enable colored output.

Petitest.configuration.color = true

color_scheme

Color scheme for colored output.

Petitest.configuration.color_scheme = {
  detail: :cyan,
  error: :red,
  pass: :green,
  skip: :yellow,
}

These color types are available on color scheme configuration:

  • :black
  • :blue
  • :bold
  • :cyan
  • :green
  • :magenta
  • :red
  • :white
  • :yellow

output

Output path for some subscribers.

Petitest.configuration.output = ::STDOUT
Petitest.configuration.output.sync = true

subscribers

Test event subscribers (test reporters are kind of subscribers).

Petitest.configuration.subscribers = [
  ::Petitest::Subscribers::DocomentReportSubscriber.new,
]

These subscribers are provided by default:

  • Petitest::Subscribers::DocumentReportSubscriber (default)
  • Petitest::Subscribers::JsonReportSubscriber
  • Petitest::Subscribers::ProgressReportSubscriber

Official Plugins

Here are some official plugins for Petitest:

For developers

Tree

TestPlan
|---Test 1
|---Test 2
|---Test 3
|---TestGroup 1
|   |---Test 1-1
|   |---Test 1-2
|   |---Test 1-3
|   `---TestGroup1-1
|       |---Test 1-1-1
|       |---Test 1-1-2
|       `---Test 1-1-3
|---TestGroup2
|   |---Test 2-1
|   |---Test 2-2
|   `---Test 2-3
`---TestGroup3
    |---Test 3-1
    |---Test 3-2
    |---Test 3-3
    `---TestGroup3-1
        |---Test 3-1-1
        |---Test 3-1-2
        `---Test 3-1-3

Order

  • Test 1
  • Test 2
  • Test 3
  • Test 1-1
  • Test 1-2
  • Test 1-3
  • Test 1-1-1
  • Test 1-1-2
  • Test 1-1-3
  • Test 2-1
  • Test 2-2
  • Test 2-3
  • Test 3-1
  • Test 3-2
  • Test 3-3
  • Test 3-1-1
  • Test 3-1-2
  • Test 3-1-3

Events

  • #before_running_test_plan(test_plan)
  • #before_running_test_group(test_group)
  • #before_running_test(test)
  • #after_running_test(test)
  • #after_running_test_group(test_group)
  • #after_running_test_plan(test_plan)

FAQs

Package last updated on 25 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.