teardown and setup hooks with minitest

71 views
Skip to first unread message

Bryan Berry

unread,
Apr 12, 2012, 1:37:17 AM4/12/12
to chef-testing
class TestArkDump < MiniTest::Chef::TestCase

self.add_setup_hook {                                                                                                

}         


self.add_teardown_hook {                                                                                                
    require 'fileutils'                                                                                                                           
FileUtils.rm_r "/usr/local/foo"                                                                                                             
}         

end

Bryan Berry

unread,
Apr 12, 2012, 1:39:52 AM4/12/12
to chef-testing
sorry my emacs muscle memory triggered the premature sending of that message

how can i add frequently used variables to a minitest test case? also how can I clean up after a test? 

not having much success with add_setup_hook and add_teardown_hook

here is what I am trying to do

class TestArkDump < MiniTest::Chef::TestCase

self.add_setup_hook {                                                                                                
  @path = '/some/long/path/really/long'
}         

# use @path multiple times

self.add_teardown_hook {                                                                                                
    require 'fileutils'                                                                                                                           
FileUtils.rm_r  @path
                                                                                                            
}         

end

Reply all
Reply to author
Forward
0 new messages