-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(CAT-1488) - Refactor duplicated shared examples and context
This fixes duplicate definition warnings in the acceptance tests. Signed-off-by: Gavin Didrichsen <[email protected]>
- Loading branch information
1 parent
a0d85d2
commit c675464
Showing
5 changed files
with
38 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
spec/acceptance/support/a_saved_json_configuration_file.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |