Minitest Cheat Sheet
- Minitest Cheat Sheet Excel
- Minitest Cheat Sheet Pdf
- Minitest Cheat Sheet Printable
- Minitest Cheat Sheet
- Minitest Cheat Sheet Template
The MiniTest Assertions Cheat Sheet was released by CITguy on Cheatography. Here's how they described it: Download the PDF version here View Entire Discussion (1 Comments). Require 'minitest/autorun' # 注意有些资料中,测试类不是继承自MiniTest::Test, # 那是MiniTest 5之前的做法,MiniTest会通知你改正 class TestMyLife MiniTest:: Test # 这个方法会在各个测试之前被调用 def setup @me = People. New end def testsleep # assertequal exp, act, msg assertequal 'zzZ', @me.sleep.
Minitest Cheat Sheet Excel
Ruby’s standard testing suite, MiniTest, is in dire need of a quick-and-handy reference for its syntax. I’ve put one together comparing the unit syntax (assert/refute) and the spec syntax (must/wont). You can see it below or download the Google Spreadsheet I made and roll your own sheet (HTML, XLS)
Test syntax
| Unit | Spec | Arguments | Examples |
|---|---|---|---|
| | |
|
| | |
|
| | |
|
| |
| |
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
Test Setup
| Unit | Spec |
|---|---|
setup() | before(type = nil, &block) |
teardown() | after(type = nil, &block) |
Mocks
Minitest Cheat Sheet Pdf
via MiniTest::Mock
Minitest Cheat Sheet Printable
expect(name, retval, args=[])– Expect that method name is called, optionally with args or a blk, and returns retval.Example:
verify– Verify that all methods were called as expected. Raises MockExpectationError if the mock object was not called as expected.
Other syntax

def flunk(msg=nil)def pass(msg=nil)def skip(msg=nil, bt=caller)def it (desc='anonymous', &block)i_suck_and_my_tests_are_order_dependent!()– Call this at the top of your tests when you absolutely positively need to have ordered tests. In doing so, you’re admitting that you suck and your tests are weak. (TestCase public class method)parallelize_me!()– Call this at the top of your tests when you want to run your tests in parallel. In doing so, you’re admitting that you rule and your tests are awesome.make_my_diffs_pretty!()– Make diffs for this TestCase use pretty_inspect so that diff in assert_equal can be more details. NOTE: this is much slower than the regular inspect but much more usable for complex objects.
Tutorials
Reference
- My Google Spreadsheet of MiniTest calls, as Excel
- StackOverflow: How do I mock things in MiniTest?

Brought to you by
Welcome. Free Books in the Yuki & Moto Press Series about Ruby 'n' Friends include:
Gem Developer's Guide by , , et al (Source in the Manuscripts book format)
How I Start - Let's Build a Gem Together! by (Source in the Manuscripts book format)
Hoe Developer's Guide - Build, Package and Publish Gems with Rake Tasks - Ready-to-Use Build Scripts by , et al (Source in the Manuscripts book format)
Minitest Cheat Sheet
Sinatra Intro by , , et al (Source in the Manuscripts book format)
Best of Practicing Ruby by , , , , , et al (Source in the Manuscripts book format)
Programming Blockchains Step-by-Step from Scratch (Zero). Starting with Crypto Hashes... by , et al (Source in the Manuscripts book format)
Gem Series ++ Programming Cryptocurrencies and Blockchains by , et al (Source in the Manuscripts book format)
Gem Series ++ Project Automation & Database Documentation Tools by , et al (Source in the Manuscripts book format)
Minitest Cheat Sheet Template
Gem Series ++ Web Services (HTTP JSON APIs) the Modern Micro Way by , et al (Source in the Manuscripts book format)
Net::HTTP by Example / Net::HTTP Cheat Sheet by , et al (Source in the Manuscripts book format)
FizzBuzz (1, 2, Fizz, 4, Buzz,...) by Example - There's More Than One Way To Do It by , , et al (Source in the Manuscripts book format)
Ruby Best Practices by (Source in the Manuscripts book format)
More Bookshelves
Bits & Blocks Press • Hyde Press • Fun Press • World Classics Built with Octobook (powered by Jekyll) on 2018-05-11 08:33:54 +0000 in 2.371 seconds.
Hosted on GitHub Pages. </> Source on GitHub. (0) Dedicated to the public domain.

