summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-09-14 16:59:36 -0600
committermo khan <mo.khan@gmail.com>2020-09-14 16:59:36 -0600
commit853ae09d4c6d0220a3f77492065961e65f96e860 (patch)
tree6986ed03dfa7545d483c980a31b0ce83582a2811 /spec/support
parent0dc0c0cec97cbdea04e278143e4711cfa0d3bd03 (diff)
chore: move classes into lib dir
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/docker.rb29
-rw-r--r--spec/support/project.rb42
2 files changed, 0 insertions, 71 deletions
diff --git a/spec/support/docker.rb b/spec/support/docker.rb
deleted file mode 100644
index 331ee17..0000000
--- a/spec/support/docker.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-class Docker
- DEFAULT_ENV = { 'CI_PROJECT_DIR' => '/tmp/app' }.freeze
- attr_reader :pwd
-
- def initialize(pwd: Pathname.pwd)
- @pwd = pwd
- end
-
- def build(tag:)
- Dir.chdir pwd do
- system("docker build --network=host -t #{tag} .")
- end
- end
-
- def run(image:, project_path: Pathname.pwd, env: {})
- env_options = DEFAULT_ENV.merge(env).map { |(key, value)| "--env #{key}=#{value}" }
- Dir.chdir pwd do
- system([
- :docker, :run, '-it', '--rm',
- '--volume', "#{project_path}:/tmp/app",
- '--network=host',
- env_options,
- image, '/analyzer run'
- ].flatten.map(&:to_s).join(' '))
- end
- end
-end
diff --git a/spec/support/project.rb b/spec/support/project.rb
deleted file mode 100644
index a90dfd6..0000000
--- a/spec/support/project.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-require 'securerandom'
-
-class Project
- attr_reader :path
-
- def initialize(path = Pathname.pwd.join('tmp').join(SecureRandom.uuid))
- FileUtils.mkdir_p(path)
- @path = Pathname(path)
- end
-
- def mount(dir:)
- FileUtils.cp_r("#{dir}/.", path)
- end
-
- def chdir
- Dir.chdir path do
- yield
- end
- end
-
- def clone(repo, branch: 'master')
- if branch.match?(/\b[0-9a-f]{5,40}\b/)
- execute({}, 'git', 'clone', '--quiet', repo, path.to_s)
- chdir do
- execute({}, 'git', 'checkout', branch)
- end
- else
- execute({}, 'git', 'clone', '--quiet', '--depth=1', '--single-branch', '--branch', branch, repo, path.to_s)
- end
- end
-
- def execute(env = {}, *args)
- Bundler.with_unbundled_env do
- system(env, *args, exception: true)
- end
- end
-
- def cleanup
- FileUtils.rm_rf(path) if path.exist?
- end
-end