Sha256: 279718235407ae5f3fa1b04e915bcd89f8168f3a0ab6443c907394aa4ce9442a

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'
require 'scrutinizer/ocular/repository_introspector'

describe Scrutinizer::Ocular::RepositoryIntrospector do

  repo_dir = nil
  introspector = nil

  before do
    repo_dir = "/tmp/repo-inspector-rb"

    if Dir.exists? repo_dir
      system("rm -rf " + repo_dir)
    end

    Dir.mkdir(repo_dir)
    system("git init 1>/dev/null", :chdir => repo_dir)
    introspector = Scrutinizer::Ocular::RepositoryIntrospector.new(repo_dir)
  end

  it "returns the current revision" do
    system("echo 'foo' > " + repo_dir + "/foo && git add . && git commit -m 'Foo' 1>/dev/null", :chdir => repo_dir)
    introspector.get_current_revision.should match(/^[a-f0-9]{40}$/)
  end

  it "returns the parents of the revision" do
    system("echo 'foo' > " + repo_dir + "/foo && git add . && git commit -m 'Foo' 1>/dev/null", :chdir => repo_dir)
    base_rev = introspector.get_current_revision
    introspector.get_current_parents.should eql?([])

    system("echo 'bar' > " + repo_dir + "/bar && git add . && git commit -m 'Bar' 1>/dev/null", :chdir => repo_dir)
    introspector.get_current_parents.should eql?([base_rev])
  end

  it "returns the GitHub repository name" do
    system("git remote add origin git@github.com:scrutinizer-ci/ocular.rb", :chdir => repo_dir)
    introspector.get_repository_name.should eql?("g/scrutinizer-ci/ocular.rb")

    system("git remote set-url origin git://github.com:scrutinizer-ci/ocular.rb", :chdir => repo_dir)
    introspector.get_repository_name.should eql?("g/scrutinizer-ci/ocular.rb")
  end

  after do
    unless repo_dir.nil?
      system("rm -rf " + repo_dir)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scrutinizer-ocular-1.0.1 spec/scrutinizer/ocular/repository_introspector_spec.rb
scrutinizer-ocular-1.0.0 spec/scrutinizer/ocular/repository_introspector_spec.rb