Sha256: a0a9a94e4d5262311cd9268fcb8ee0078264f49028eafb528d5ee771d5d643ec

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

# Run with:
# ruby -Ilib examples/foobar_test.rb

require 'test_construct'
require 'test/unit'

class FoobarTest < Test::Unit::TestCase
  include TestConstruct::Helpers

  def test_directory_and_files
    within_construct do |c|
      c.directory 'alice/rabbithole' do |d|
        d.file 'white_rabbit.txt', "I'm late!"

        assert_equal "I'm late!", File.read('white_rabbit.txt')
      end
    end
  end

  def test_keeping_directory_on_error
    within_construct(keep_on_error: true) do |c|
      c.directory 'd' do |d|
        d.file 'doughnut.txt'
        raise "whoops"
      end
    end
  end

  def test_deleting_directory_on_error
    within_construct(keep_on_error: false) do |c|
      c.directory 'd' do |d|
        d.file 'doughnut.txt'
        raise "whoops"
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
test_construct-2.0.2 examples/foobar_test.rb
test_construct-2.0.1 examples/foobar_test.rb
test_construct-2.0.0 examples/foobar_test.rb