Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinistock/loupe
A toy Ruby test framework with built in parallelism
https://github.com/vinistock/loupe
framework parallel ractor ruby test
Last synced: 6 days ago
JSON representation
A toy Ruby test framework with built in parallelism
- Host: GitHub
- URL: https://github.com/vinistock/loupe
- Owner: vinistock
- License: other
- Created: 2021-03-08T01:46:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T04:59:43.000Z (over 1 year ago)
- Last Synced: 2024-10-23T03:07:43.481Z (15 days ago)
- Topics: framework, parallel, ractor, ruby, test
- Language: Ruby
- Homepage:
- Size: 260 KB
- Stars: 67
- Watchers: 4
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Loupe
Loupe is the toy test framework used in the talk [Parallel testing with Ractors: putting CPUs to work](https://www.youtube.com/watch?v=bvFj6_dulSo).
## Installation
Add the gem to the `Gemfile`.
```ruby
gem "loupe"
```And then execute:
```shell
bundle install
```Install bundler binstubs in your application.
```shell
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.
```ruby
# frozen_string_literal: trueclass MyTest < Loupe::Test
def before
@author = Author.create(name: "John")
@post = Post.create(author: @author)
enddef after
@author.destroy
@post.destroy
enddef 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.
```shell
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.
```shell
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.
```ruby
# Rakefilerequire "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
```shell
bundle exec rake test
```## Credits
This project draws a lot of inspiration from other Ruby test frameworks, namely
- [Minitest](https://github.com/seattlerb/minitest)
- [rspec](https://github.com/rspec/rspec)## Contributing
Please refer to the guidelines in [contributing](https://github.com/vinistock/loupe/blob/master/CONTRIBUTING.md).