Sha256: 5c25c94c4fa9b26d8b9dc0dd4fd75da2b945cbcf983f84b99601d118a1b655f0

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
require 'ronin/repos'

describe Ronin::Repos do
  it "should have a version" do
    expect(subject.const_defined?('VERSION')).to be(true)
  end

  let(:cache_dir) { described_class.class_variable_get('@@cache_dir') }

  describe "@@cache_dir" do
    subject { cache_dir }

    it "must be a CacheDir pointing to ~/.cache/ronin-repos" do
      expect(subject).to be_kind_of(CacheDir)
      expect(subject.path).to eq(File.expand_path("~/.cache/ronin-repos"))
    end
  end

  describe ".find_file" do
    let(:relative_path) { 'file.txt' }
    let(:matches) do
      [
        "/path/to/repo1/file.txt",
        "/path/to/repo2/file.txt"
      ]
    end

    it "must call @@cache_dir.find_file" do
      expect(cache_dir).to receive(:find_file).with(relative_path).and_return(matches)

      expect(subject.find_file(relative_path)).to be(matches)
    end
  end

  describe ".glob" do
    let(:pattern) { 'dir/*.txt' }
    let(:matches) do
      [
        "/path/to/repo1/dir/file.txt",
        "/path/to/repo2/dir/file.txt"
      ]
    end

    it "must call @@cache_dir.glob" do
      expect(cache_dir).to receive(:glob).with(pattern).and_return(matches)

      expect(subject.glob(pattern)).to be(matches)
    end
  end

  describe ".list_files" do
    let(:pattern) { 'dir/*.txt' }
    let(:files) do
      Set[
        "dir/file.txt",
        "dir/file.txt"
      ]
    end

    it "must call @@cache_dir.list_files" do
      expect(cache_dir).to receive(:list_files).with(pattern).and_return(files)

      expect(subject.list_files(pattern)).to be(files)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-repos-0.1.0.beta1 spec/repos_spec.rb