Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b16361ad7a
Fetching contributors…

Cannot retrieve contributors at this time

file 40 lines (34 sloc) 1.011 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
require 'helper'
require 'find'

module Busted
  module Collectors
    class TestGemArchiver < TestCase
      def setup
        @scratch_dir = File.join(Dir.tmpdir, Time.now.to_i.to_s)
        FileUtils.mkdir_p @scratch_dir
        @ga = GemArchiver.new @scratch_dir

        dep = ::Gem::Dependency.new('', ::Gem::Requirement.default)
        specs = ::Gem.source_index.search dep
        @spec = specs.first
      end

      def test_save_to_scratch_dir
        dir = @ga.process @spec
        assert_match @scratch_dir, dir
      end

      def test_process
        dir = @ga.process @spec
        bn = File.basename(@spec.full_gem_path)
        expected = []
        actual = []

        Find.find(dir) do |path|
          actual << path.sub(/^.*#{bn}/, '')
        end
        Find.find(@spec.full_gem_path) do |path|
          expected << path.sub(/^.*#{bn}/, '')
        end

        assert_equal expected.length, actual.length
        assert_equal expected.sort, actual.sort
      end
    end
  end
end
Something went wrong with that request. Please try again.