Skip to content

Commit

Permalink
Fix test specs (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfurrow authored Aug 22, 2021
1 parent 339f47f commit 702b717
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
9 changes: 5 additions & 4 deletions spec/integration/native-osx_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
include Rspec::Bash

let(:env) { create_stubbed_env }
let(:dir) { Dir.tmpdir }
let(:bin) { File.expand_path(File.join(__dir__, '..', '..', 'bin', 'docker-sync')) }
let(:config_file_template) { File.expand_path(File.join(__dir__, '..', '..', 'spec', 'fixtures', 'native_osx', 'docker-sync.yml')) }
let(:config_file_path) { File.join(env.dir, 'docker-sync.yml') }
let(:config_file_path) { File.join(dir, 'docker-sync.yml') }
let(:host_app_template) { 'spec/fixtures/app_skeleton' }
let(:host_app_path) { File.join(env.dir, File.basename(host_app_template)) }
let(:host_app_path) { File.join(dir, File.basename(host_app_template)) }
let(:test_env_vars) { { 'DOCKER_SYNC_SKIP_UPGRADE' => 'true', 'DOCKER_SYNC_SKIP_UPDATE' => 'true', 'DOCKER_SYNC_SKIP_DEPENDENCIES_CHECK' => 'true' } }

before :all do
Expand All @@ -21,8 +22,8 @@

describe 'start' do
around(:each) do |example|
FileUtils.cp_r([host_app_template, config_file_template], env.dir)
FileUtils.chdir(env.dir) do
FileUtils.cp_r([host_app_template, config_file_template], dir)
FileUtils.chdir(dir) do
replace_in_file(config_file_path, '{{HOST_APP_PATH}}', "'#{host_app_path}'")
_stdout, stderr, status = env.execute_inline("#{bin} start", test_env_vars)
raise stderr unless status.success?
Expand Down
27 changes: 22 additions & 5 deletions spec/lib/docker-sync/project_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@
require 'docker-sync/config/project_config'

RSpec.describe DockerSync::ProjectConfig do
let(:default_sync_strategy) { OS.linux? ? 'native' : 'unison' }
let(:default_watch_strategy) { OS.linux? ? 'dummy' : 'unison' }
let(:default_sync_strategy) do
if OS.linux?
'native'
elsif OS.mac?
'native_osx'
else
'unison'
end
end
let(:default_watch_strategy) do
if OS.linux?
'dummy'
elsif OS.mac?
'remotelogs'
else
'unison'
end
end

subject { described_class.new }
before do
allow(DockerSync::Dependencies::Docker::Driver).to receive(:system).with('pgrep -q com.docker.hyperkit').and_return(true)
allow(DockerSync::Environment).to receive(:system).with('pgrep -q com.docker.hyperkit').and_return(true)
end

describe '#initialize' do
Expand Down Expand Up @@ -305,9 +321,10 @@

describe '#unison_required?' do
it do
allow(DockerSync::Dependencies::Docker::Driver).to receive(:system).with('pgrep -q com.docker.hyperkit').and_return(true)
allow(DockerSync::Environment).to receive(:system).with('pgrep -q com.docker.hyperkit').and_return(true)

use_fixture 'simplest' do
if OS.linux?
if OS.linux? || OS.mac?
is_expected.not_to be_unison_required
else
is_expected.to be_unison_required
Expand Down

0 comments on commit 702b717

Please sign in to comment.