Sha256: f4111abb3d10c53d0521121610c3e85dc55db4cffe0d6e17f8f5aa83843b17c6

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

module FS
  module SpecHelpers
    
    def self.extended(example_group)
      example_group.use_helper(example_group)
    end

    def self.included(example_group)
      example_group.extend self
    end

    def use_helper(describe_block)
      describe_block.before :each do
        unless @test_dir
          @test_dir = File.realpath(Dir.mktmpdir('test_'))
          Dir.chdir(@test_dir)
        end
      end

      describe_block.after :each do
        if @test_dir
          FileUtils.rm_r(@test_dir)
          @test_dir = nil
        end
      end
    end
    
  end
end

RSpec.configure do |config|
  config.include FS::SpecHelpers
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fs-0.2.0 spec/support/test_dir_support.rb
fs-0.1.2 spec/support/test_dir_support.rb
fs-0.1.1 spec/support/test_dir_support.rb