Class: MiniTest::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/pantry/test/support/mock_ui.rb,
lib/pantry/test/support/fake_fs.rb

Overview

Hook up FakeFS into Minitest

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fake_fs!Object



6
7
8
9
10
11
12
13
14
15
# 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!Object



5
6
7
8
9
10
11
12
# 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

Instance Method Details

#stdinObject

Get access to the mock of STDIN to add values



20
21
22
# File 'lib/pantry/test/support/mock_ui.rb', line 20

def stdin
  @mock_stdin
end

#stdoutObject

Return the strings added to stdout through the test



15
16
17
# File 'lib/pantry/test/support/mock_ui.rb', line 15

def stdout
  @mock_stdout.string
end