Sha256: 2c8fe0d35b09ae92127ca283a2d4a981121da58b63395026976d5ce85d778f3a

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 KB

Contents

require 'fileutils'
require 'securerandom'

RSpec.shared_context 'uses aruba API' do
  def random_string(options = {})
    options[:prefix].to_s + SecureRandom.hex + options[:suffix].to_s
  end

  def create_test_files(files, data = 'a')
    Array(files).each do |s|
      next if s.to_s[0] == '%'
      local_path = expand_path(s)

      FileUtils.mkdir_p File.dirname(local_path)
      File.open(local_path, 'w') { |f| f << data }
    end
  end

  before(:each) do
    klass = Class.new do
      include Aruba::Api

      def set_tag(tag_name, value)
        self.instance_variable_set "@#{tag_name}", value
      end
    end

    @aruba = klass.new

    @file_name = "test.txt"
    @file_size = 256
    @file_path = @aruba.expand_path(@file_name)
    @aruba.setup_aruba

    raise "We must work with relative paths, everything else is dangerous" if ?/ == @aruba.aruba.current_directory[0]
  end
end

RSpec.shared_context 'needs to expand paths' do
  def expand_path(*args)
    @aruba.expand_path(*args)
  end
end

RSpec.shared_context 'needs to run with environment' do
  def with_environment(*args, &block)
    @aruba.with_environment(*args, &block)
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
aruba-0.14.14 spec/support/shared_contexts/aruba.rb
aruba-0.14.13 spec/support/shared_contexts/aruba.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/aruba-0.14.12/spec/support/shared_contexts/aruba.rb
aruba-0.14.12 spec/support/shared_contexts/aruba.rb
aruba-0.14.11 spec/support/shared_contexts/aruba.rb
aruba-0.14.10 spec/support/shared_contexts/aruba.rb
aruba-0.14.9 spec/support/shared_contexts/aruba.rb
aruba-0.14.8 spec/support/shared_contexts/aruba.rb
aruba-0.14.7 spec/support/shared_contexts/aruba.rb
aruba-0.14.6 spec/support/shared_contexts/aruba.rb
aruba-0.14.5 spec/support/shared_contexts/aruba.rb
aruba-0.14.4 spec/support/shared_contexts/aruba.rb
aruba-0.14.3 spec/support/shared_contexts/aruba.rb