loupe

Loupe

Loupe is a test framework with built in parallel execution supporting Ractor or forked process modes.

Installation

Add the gem to the Gemfile.

gem "loupe"

And then execute:

bundle install

Install bundler binstubs in your application.

bundle binstub loupe

Usage

Currently, Loupe only supports writing tests using the test methods syntax. Tests must inherit from Loupe::Test, but do not need to explicitly require test_helper, like the example below.

# frozen_string_literal: true

class MyTest < Loupe::Test
  def before
    @author = Author.create(name: "John")
    @post = Post.create(author: @author)
  end

  def after
    @author.destroy
    @post.destroy
  end

  def test_post_is_linked_to_author
    expect(@post.author.name).to_be_equal_to("John")
  end
end

To run the test suite, invoke the executable using the binstub generated by bundler.

bin/loupe test/post_test.rb test/author_test.rb

Tests can run in parallel using Ractor or process mode. When using Ractors, the application's code must be Ractor compatible.

bin/loupe --ractor            # [default] run tests using Ractor workers
bin/loupe --process           # run tests using forked processes
bin/loupe --interactive       # [default] use an interactive reporter to display test results
bin/loupe --plain             # use a plain reporter to display test results
bin/loupe --color, --no-color # enable/disable output colors
bin/loupe --editor=EDITOR     # which editor to use for opening files when using interactive mode. The default is the environment variable $EDITOR

To hook Loupe into Rake, use the provided rake task as in the example below.

# Rakefile

require "loupe/rake_task"

# Instantiate the task and append any desired CLI options
Loupe::RakeTask.new do |options|
  options << "--plain"
end

# Optionally, set the default task to be test
task default: :test

Then run

bundle exec rake test

Credits

This project draws a lot of inspiration from other Ruby test frameworks, namely

Contributing

Please refer to the guidelines in contributing.