https://github.com/mitchellh/minitest-funcarg
Proof of concept showing funcargs (style of DI) in minitest.
https://github.com/mitchellh/minitest-funcarg
Last synced: about 2 months ago
JSON representation
Proof of concept showing funcargs (style of DI) in minitest.
- Host: GitHub
- URL: https://github.com/mitchellh/minitest-funcarg
- Owner: mitchellh
- Created: 2011-09-15T19:56:25.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-09-15T19:56:35.000Z (almost 14 years ago)
- Last Synced: 2025-04-26T03:34:36.410Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 89.8 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# minitest-funcarg
This is an extension to [minitest](https://github.com/seattlerb/minitest)
which adds the ability to use funcargs as a method of test-level isolation.
Funcargs are a form of [dependency injection](http://en.wikipedia.org/wiki/Dependency_injection).**WARNING:** This is a _proof of concept_. It works, but is not intended --
in its current form -- to be used for production tests.## Example
### Defining And Using Funcargs
Define a test class:
```ruby
require "minitest/autorun"
require "minitest/unit"
require "minitest/funcarg"class MyTest < MiniTest::Unit::TestCase
def minitest_funcarg__number
return 7
enddef test_things(number)
assert number > 0
end
end
```Run them:
$ ruby my_test.rb
Started
.
Finished in 0.000343 seconds.1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
The result is that the `number` parameter for `test_things` was given
as the number 7 since that is what the magic method
`minitest_funcarg__number` returned.