summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-04-01 13:25:54 +1300
committerThong Kuah <tkuah@gitlab.com>2019-04-01 14:37:54 +1300
commit32a1277d28a87f92a87218a60c32174f4c7279a9 (patch)
tree18f31c4f47615c26017ca0c8c11ccdeab1a6337d
parent5cd63ace04deee2e6d7c13694bfd8dc46d0edaf4 (diff)
downloadgitlab-ce-32a1277d28a87f92a87218a60c32174f4c7279a9.tar.gz
Fix license_template_spec to not modify String
Revamp how spec verifies proc#call called only once
-rw-r--r--spec/models/license_template_spec.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/spec/models/license_template_spec.rb b/spec/models/license_template_spec.rb
index a0224ec2f58..7037277e580 100644
--- a/spec/models/license_template_spec.rb
+++ b/spec/models/license_template_spec.rb
@@ -5,14 +5,15 @@ require 'spec_helper'
describe LicenseTemplate do
describe '#content' do
it 'calls a proc exactly once if provided' do
- lazy = build_template(-> { 'bar' })
- content = lazy.content
+ content_proc = -> { 'bar' }
+ expect(content_proc).to receive(:call).once.and_call_original
- expect(content).to eq('bar')
- expect(content.object_id).to eq(lazy.content.object_id)
+ lazy = build_template(content_proc)
- content.replace('foo')
- expect(lazy.content).to eq('foo')
+ expect(lazy.content).to eq('bar')
+
+ # Subsequent calls should not call proc again
+ expect(lazy.content).to eq('bar')
end
it 'returns a string if provided' do