diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-04-01 03:25:54 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-04-01 04:37:54 +0300 |
commit | 32a1277d28a87f92a87218a60c32174f4c7279a9 (patch) | |
tree | 18f31c4f47615c26017ca0c8c11ccdeab1a6337d /spec/models/license_template_spec.rb | |
parent | 5cd63ace04deee2e6d7c13694bfd8dc46d0edaf4 (diff) |
Fix license_template_spec to not modify String
Revamp how spec verifies proc#call called only once
Diffstat (limited to 'spec/models/license_template_spec.rb')
-rw-r--r-- | spec/models/license_template_spec.rb | 13 |
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 |