Skip to content

Commit f7a9461

Browse files
committed
Add GIT_COMMIT env as a comment to the XML output file
1 parent 467612d commit f7a9461

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

lib/alma/xml_writer.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def ensure_open!
4040
end
4141

4242
def prolog_and_opening_tag
43-
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<users>\n"
43+
tag = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
44+
tag += "<!-- GIT_COMMIT:#{ENV['GIT_COMMIT']} -->\n"
45+
tag += "<users>\n"
46+
tag
4447
end
4548

4649
def ensure_io(file)

spec/data/sis/expected_xml_3.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- GIT_COMMIT:LOCAL_TESTING -->
23
<users>
34
<user>
45
<record_type>PUBLIC</record_type>

spec/data/ucpath/expected_xml_1.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- GIT_COMMIT:LOCAL_TESTING -->
23
<users>
34
<user>
45
<record_type>PUBLIC</record_type>

spec/lib/alma_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
Alma::XMLWriter.open(out) { |w| w.write(@student_rec) }
3838
actual = File.read(out)
3939
xml = Alma::XMLBuilder.new(@student_rec).build
40-
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<users>\n#{xml}\n</users>"
40+
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- GIT_COMMIT:LOCAL_TESTING -->\n<users>\n#{xml}\n</users>"
4141
expect(actual).to eq(expected)
4242
end
4343
end
@@ -51,7 +51,7 @@
5151
actual = File.read(out)
5252

5353
xml = Alma::XMLBuilder.new(@student_rec).build
54-
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<users>\n#{xml}\n</users>"
54+
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- GIT_COMMIT:LOCAL_TESTING -->\n<users>\n#{xml}\n</users>"
5555

5656
expect(actual).to eq(expected)
5757
end

spec/spec_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
#
3737
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
3838
RSpec.configure do |config|
39+
# Mock ENVs for testing
40+
config.before(:each) do
41+
ENV['GIT_COMMIT'] = 'LOCAL_TESTING'
42+
end
43+
3944
config.color = true
4045
config.tty = true
4146
config.formatter = :documentation

0 commit comments

Comments
 (0)