Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CAT-1488) - Fix windows acceptance tests #1281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions spec/acceptance/remove_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,6 @@
describe 'pdk remove config' do
include_context 'with a fake TTY'

shared_examples 'a saved configuration file' do |new_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
expect(actual_content).to eq(new_content)
end
end

shared_examples 'a saved JSON configuration file' do |new_json_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content_raw = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
actual_json_content = JSON.parse(actual_content_raw)
expect(actual_json_content).to eq(new_json_content)
end
end

RSpec.shared_context 'with a fake answer file' do |initial_content = nil|
before(:all) do
fake_answer_file = Tempfile.new('mock_answers.json')
unless initial_content.nil?
require 'json'
fake_answer_file.binmode
fake_answer_file.write(JSON.pretty_generate(initial_content))
end
fake_answer_file.close
ENV['PDK_ANSWER_FILE'] = fake_answer_file.path
end

after(:all) do
FileUtils.rm_f(ENV.fetch('PDK_ANSWER_FILE', nil)) # Need actual file calls here
ENV.delete('PDK_ANSWER_FILE')
end
end

context 'when run outside of a module' do
describe command('pdk remove config') do
its(:exit_status) { is_expected.not_to eq 0 }
Expand Down
41 changes: 0 additions & 41 deletions spec/acceptance/set_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,6 @@
describe 'pdk set config' do
include_context 'with a fake TTY'

shared_examples 'a saved configuration file' do |new_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
expect(actual_content).to eq(new_content)
end
end

shared_examples 'a saved JSON configuration file' do |new_json_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content_raw = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
actual_json_content = JSON.parse(actual_content_raw)
expect(actual_json_content).to eq(new_json_content)
end
end

RSpec.shared_context 'with a fake answer file' do |initial_content = nil|
before(:all) do
fake_answer_file = Tempfile.new('mock_answers.json')
unless initial_content.nil?
require 'json'
fake_answer_file.binmode
fake_answer_file.write(JSON.pretty_generate(initial_content))
end
fake_answer_file.close
ENV['PDK_ANSWER_FILE'] = fake_answer_file.path
end

after(:all) do
FileUtils.rm_f(ENV.fetch('PDK_ANSWER_FILE', nil)) # Need actual file calls here
ENV.delete('PDK_ANSWER_FILE')
end
end

context 'when run outside of a module' do
describe command('pdk set config') do
its(:exit_status) { is_expected.not_to eq 0 }
Expand Down
10 changes: 10 additions & 0 deletions spec/acceptance/support/a_saved_configuration_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec.shared_examples 'a saved configuration file' do |new_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
expect(actual_content).to eq(new_content)
end
end
11 changes: 11 additions & 0 deletions spec/acceptance/support/a_saved_json_configuration_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RSpec.shared_examples 'a saved JSON configuration file' do |new_json_content|
it 'saves the setting' do
# Force the command to run if not already
subject.exit_status
expect(File).to exist(ENV.fetch('PDK_ANSWER_FILE', nil))

actual_content_raw = File.open(ENV.fetch('PDK_ANSWER_FILE', nil), 'rb:utf-8', &:read)
actual_json_content = JSON.parse(actual_content_raw)
expect(actual_json_content).to eq(new_json_content)
end
end
17 changes: 17 additions & 0 deletions spec/acceptance/support/with_a_fake_answer_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
RSpec.shared_context 'with a fake answer file' do |initial_content = nil|
before(:all) do
fake_answer_file = Tempfile.new('mock_answers.json')
unless initial_content.nil?
require 'json'
fake_answer_file.binmode
fake_answer_file.write(JSON.pretty_generate(initial_content))
end
fake_answer_file.close
ENV['PDK_ANSWER_FILE'] = fake_answer_file.path
end

after(:all) do
FileUtils.rm_f(ENV.fetch('PDK_ANSWER_FILE', nil)) # Need actual file calls here
ENV.delete('PDK_ANSWER_FILE')
end
end
8 changes: 5 additions & 3 deletions spec/acceptance/test_unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
include_context 'with a fake TTY'

shared_context 'with spec file' do |filename, content|
around(:all) do |example|
path = File.join('spec', 'unit', filename)
path = File.join('spec', 'unit', filename)
before(:all) do
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') { |f| f.puts content }
example.run
end

after(:all) do
FileUtils.rm_f(path)
end
end
Expand Down