9 require 'minitest/autorun'
15 let(:list) { Array.new }
22 ### Specs (.must/.wont)
27 .must_be_close_to 2.99999
40 .must_be_silent ( proc { "no stdout or stderr" }.must_be_silent)
43 proc { ... }.must_output out_or_nil [, err]
44 proc { ... }.must_raise exception
45 proc { ... }.must_throw sym
49 class TestHipster < Minitest::Test
51 @subject = ["silly hats", "skinny jeans"]
58 def test_for_helvetica_font
59 assert_equal "helvetica!", @hipster.preferred_font
62 def test_not_mainstream
63 refute @hipster.mainstream?
73 assert_in_delta @size, 1, 1
75 assert_includes @list, "item"
76 assert_instance_of Array, @list
77 assert_kind_of Enumerable, @list
78 assert_match @str, /regex/
80 assert_operator @n, :==, 0
91 A simple and clean mock system. There two essential methods at our disposal: expect and verify.
93 require 'minitest/autorun'
95 describe Twipster, "Make every tweet a hipster tweet." do
97 @twitter = Minitest::Mock.new
98 @twipster = Twipster.new(@twitter)
101 it "should append a #lolhipster hashtag and update Twitter with our status" do
102 tweet = "Skyrim? Too mainstream."
103 @twitter.expect :update, true, ["#{tweet} #lolhipster"]
104 @twipster.submit(tweet)
105 assert @twitter.verify # verifies tweet and hashtag was passed to `@twitter.update`
111 gem 'minitest-reporters'
113 require 'minitest/reporters'
114 Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
116 [Default, Spec, Progress, RubyMate, RubyMine, JUnit]