Module: TestConstruct::Helpers
Instance Method Summary collapse
Instance Method Details
#create_construct(chdir = true) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/test_construct/helpers.rb', line 16 def create_construct(chdir = true) path = (Pathname(TestConstruct.tmpdir) + "#{CONTAINER_PREFIX}-#{$PROCESS_ID}-#{rand(1_000_000_000)}") path.mkpath path.extend(PathnameExtensions) path.construct__chdir_default = chdir path end |
#within_construct(opts = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/test_construct/helpers.rb', line 6 def within_construct(opts = {}) chdir = opts.fetch(:chdir, true) container = create_construct(chdir) container.maybe_change_dir(chdir) do yield(container) end ensure container.destroy! if container.respond_to?(:destroy!) end |