1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Running A Single MiniTest Example as a ruby til

This commit is contained in:
jbranchaud
2016-04-02 11:23:33 -05:00
parent 8fbb29c127
commit 69b290b0d4
2 changed files with 37 additions and 0 deletions

View File

@@ -296,6 +296,7 @@ _381 TILs and counting..._
- [Replace The Current Process With An External Command](ruby/replace-the-current-process-with-an-external-command.md)
- [Rendering ERB](ruby/rendering-erb.md)
- [Returning With Sequel](ruby/returning-with-sequel.md)
- [Running A Single MiniTest Example](ruby/running-a-single-minitest-example.md)
- [Safe Navigation Operator](ruby/safe-navigation-operator.md)
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md)

View File

@@ -0,0 +1,36 @@
# Running A Single MiniTest Example
Consider the following
[MiniTest](http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest.html)
file:
```ruby
# test_stuff.rb
require 'minitest/autorun'
class TestStuff < MiniTest::Unit::TestCase
def test_first_thing
assert_equal 4, (2 * 2)
end
def test_second_thing
assert_equal 9, (3 * 3)
end
end
```
If we want to run all the tests in this file, we can do so with:
```bash
$ ruby test_stuff.rb
```
But what if we want to run a specific test? We can target a single MiniTest
example with the `--name` flag and the name of that example. We can do
something like the following:
```bash
$ ruby test_stuff.rb --name test_second_thing
```
[source](http://stackoverflow.com/a/5292885/535590)