Skip to content
Snippets Groups Projects
Commit 952004d0 authored by Robert Speicher's avatar Robert Speicher
Browse files

Merge branch 'rs-simplify-spec-helper' into 'master'

Simplify spec_helper

See merge request !138
parents 5cc153ae 1340011a
No related branches found
No related tags found
1 merge request!138Simplify spec_helper
Pipeline #
*.gem
support/*
tmp/*
coverage/*
.DS_Store
Gemfile.lock
/Gemfile.lock
/coverage/*
/tmp/*
Loading
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
 
describe Gitlab::Git::Attributes do
let(:path) do
File.expand_path(File.join(SUPPORT_PATH, 'with-git-attributes.git'))
File.join(SEED_REPOSITORY_PATH, 'with-git-attributes.git')
end
 
subject { described_class.new(path) }
Loading
Loading
@@ -141,7 +141,7 @@ describe Gitlab::Git::Attributes do
end
 
it 'does not yield when the attributes file has an unsupported encoding' do
path = File.expand_path(File.join(SUPPORT_PATH, 'with-invalid-git-attributes.git'))
path = File.join(SEED_REPOSITORY_PATH, 'with-invalid-git-attributes.git')
attrs = described_class.new(path)
 
expect { |b| attrs.each_line(&b) }.not_to yield_control
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ require_relative '../lib/gitlab_git/encoding_helper'
 
describe EncodingHelper do
let(:ext_class) { Class.new { extend EncodingHelper } }
let(:binary_string) { File.join(SUPPORT_PATH, 'gitlab_logo.png') }
let(:binary_string) { File.join(SEED_REPOSITORY_PATH, 'gitlab_logo.png') }
 
describe '#encode!' do
[
Loading
Loading
Loading
Loading
@@ -4,30 +4,7 @@ SimpleCov.start
require 'gitlab_git'
require 'pry'
 
require_relative 'support/seed_helper'
require_relative 'support/commit'
require_relative 'support/empty_commit'
require_relative 'support/encoding_commit'
require_relative 'support/first_commit'
require_relative 'support/last_commit'
require_relative 'support/big_commit'
require_relative 'support/ruby_blob'
require_relative 'support/repo'
RSpec::Matchers.define :be_valid_commit do
match do |actual|
actual &&
actual.id == SeedRepo::Commit::ID &&
actual.message == SeedRepo::Commit::MESSAGE &&
actual.author_name == SeedRepo::Commit::AUTHOR_FULL_NAME
end
end
SUPPORT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), '../support')
TEST_REPO_PATH = File.join(SUPPORT_PATH, 'gitlab-git-test.git')
TEST_NORMAL_REPO_PATH = File.join(SUPPORT_PATH, "not-bare-repo.git")
TEST_MUTABLE_REPO_PATH = File.join(SUPPORT_PATH, "mutable-repo.git")
TEST_BROKEN_REPO_PATH = File.join(SUPPORT_PATH, "broken-repo.git")
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
 
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
Loading
Loading
RSpec::Matchers.define :be_valid_commit do
match do |actual|
actual &&
actual.id == SeedRepo::Commit::ID &&
actual.message == SeedRepo::Commit::MESSAGE &&
actual.author_name == SeedRepo::Commit::AUTHOR_FULL_NAME
end
end
SEED_REPOSITORY_PATH = File.expand_path('../../tmp/repositories', __dir__)
TEST_REPO_PATH = File.join(SEED_REPOSITORY_PATH, 'gitlab-git-test.git')
TEST_NORMAL_REPO_PATH = File.join(SEED_REPOSITORY_PATH, "not-bare-repo.git")
TEST_MUTABLE_REPO_PATH = File.join(SEED_REPOSITORY_PATH, "mutable-repo.git")
TEST_BROKEN_REPO_PATH = File.join(SEED_REPOSITORY_PATH, "broken-repo.git")
module SeedHelper
GITLAB_URL = "https://gitlab.com/gitlab-org/gitlab-git-test.git"
 
def ensure_seeds
if File.exist?(SUPPORT_PATH)
FileUtils.rm_r(SUPPORT_PATH)
if File.exist?(SEED_REPOSITORY_PATH)
FileUtils.rm_r(SEED_REPOSITORY_PATH)
end
 
FileUtils.mkdir_p(SUPPORT_PATH)
FileUtils.mkdir_p(SEED_REPOSITORY_PATH)
 
create_bare_seeds
create_normal_seeds
Loading
Loading
@@ -18,7 +24,7 @@ module SeedHelper
 
def create_bare_seeds
system(git_env, *%W(git clone --bare #{GITLAB_URL}),
chdir: SUPPORT_PATH,
chdir: SEED_REPOSITORY_PATH,
out: '/dev/null',
err: '/dev/null')
end
Loading
Loading
@@ -52,7 +58,7 @@ module SeedHelper
end
 
def create_git_attributes
dir = File.join(SUPPORT_PATH, 'with-git-attributes.git', 'info')
dir = File.join(SEED_REPOSITORY_PATH, 'with-git-attributes.git', 'info')
 
FileUtils.mkdir_p(dir)
 
Loading
Loading
@@ -77,7 +83,7 @@ bla/bla.txt
end
 
def create_invalid_git_attributes
dir = File.join(SUPPORT_PATH, 'with-invalid-git-attributes.git', 'info')
dir = File.join(SEED_REPOSITORY_PATH, 'with-invalid-git-attributes.git', 'info')
 
FileUtils.mkdir_p(dir)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment