Sha256: c4093bfcfe220e78e4395a1bc8070c3457c965a468832e55ce996e74e7ac9317

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

require 'bundler'
Bundler.setup

require 'rspec'
require 'fileutils'

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require 'handbrake'

RSpec.configure do |config|
  def tmpdir(sub=nil)
    @tmpdir ||= begin
                  dirname = File.expand_path("../tmp", __FILE__)
                  FileUtils.mkdir_p dirname
                  dirname
                end
    if sub
      full = File.join(@tmpdir, sub)
      FileUtils.mkdir_p full
      full
    else
      @tmpdir
    end
  end

  config.after { FileUtils.rm_rf @tmpdir if @tmpdir }
end

module HandBrake
  module Spec
    ##
    # A stub implementation of the runner for HandBrake::CLI.
    class StaticRunner
      attr_accessor :output, :status
      ##
      # A lambda that specifies desired side effects of execution or
      # simulates things happening outside the execution but
      # simultaneous with it.
      attr_accessor :behavior
      attr_reader :actual_arguments

      def run(args)
        @actual_arguments = args
        if i = args.index('--output')
          fn = args[i + 1]
          File.open(fn, 'w') { |f| f.write 'This is the file created by --output' }
        end
        if behavior
          behavior.call
        end
        HandBrake::CLI::RunnerResult.new(output, status)
      end

      def status
        @status ||= 0
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
handbrake-0.4.0 spec/spec_helper.rb
handbrake-0.3.1 spec/spec_helper.rb
handbrake-0.3.0 spec/spec_helper.rb
handbrake-0.2.1 spec/spec_helper.rb
handbrake-0.2.0 spec/spec_helper.rb