class MiniTest::Test
Hook up FakeFS into Minitest
For actions that print out or use the console via Pantry.ui
, these helpers mock out stdout/stderr to make it easy to grab what’s printed and to inject keypresses
Public Class Methods
fake_fs!()
click to toggle source
# File lib/pantry/test/support/fake_fs.rb, line 6 def self.fake_fs! before do FakeFS.activate! end after do FakeFS.deactivate! FakeFS::FileSystem.clear end end
mock_ui!()
click to toggle source
# File lib/pantry/test/support/mock_ui.rb, line 5 def self.mock_ui! before do @mock_stdin = StringIO.new @mock_stdout = StringIO.new Pantry.reset_ui! Pantry.ui(@mock_stdin, @mock_stdout) end end
Public Instance Methods
stdin()
click to toggle source
Get access to the mock of STDIN to add values
# File lib/pantry/test/support/mock_ui.rb, line 20 def stdin @mock_stdin end
stdout()
click to toggle source
Return the strings added to stdout through the test
# File lib/pantry/test/support/mock_ui.rb, line 15 def stdout @mock_stdout.string end