8 require 'minitest/autorun'
14 let(:list) { Array.new }
21 ### Specs (.must/.wont)
26 .must_be_close_to 2.99999
39 .must_be_silent ( proc { "no stdout or stderr" }.must_be_silent)
42 proc { ... }.must_output out_or_nil [, err]
43 proc { ... }.must_raise exception
44 proc { ... }.must_throw sym
48 class TestHipster < Minitest::Test
50 @subject = ["silly hats", "skinny jeans"]
57 def test_for_helvetica_font
58 assert_equal "helvetica!", @hipster.preferred_font
61 def test_not_mainstream
62 refute @hipster.mainstream?
72 assert_in_delta @size, 1, 1
74 assert_includes @list, "item"
75 assert_instance_of Array, @list
76 assert_kind_of Enumerable, @list
77 assert_match @str, /regex/
79 assert_operator @n, :==, 0
90 A simple and clean mock system. There two essential methods at our disposal: expect and verify.
92 require 'minitest/autorun'
94 describe Twipster, "Make every tweet a hipster tweet." do
96 @twitter = Minitest::Mock.new
97 @twipster = Twipster.new(@twitter)
100 it "should append a #lolhipster hashtag and update Twitter with our status" do
101 tweet = "Skyrim? Too mainstream."
102 @twitter.expect :update, true, ["#{tweet} #lolhipster"]
103 @twipster.submit(tweet)
104 assert @twitter.verify # verifies tweet and hashtag was passed to `@twitter.update`
110 gem 'minitest-reporters'
112 require 'minitest/reporters'
113 Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
115 [Default, Spec, Progress, RubyMate, RubyMine, JUnit]