Commit 32a1277d authored by Thong Kuah's avatar Thong Kuah

Fix license_template_spec to not modify String

Revamp how spec verifies proc#call called only once
parent 5cd63ace
...@@ -5,14 +5,15 @@ require 'spec_helper' ...@@ -5,14 +5,15 @@ require 'spec_helper'
describe LicenseTemplate do describe LicenseTemplate do
describe '#content' do describe '#content' do
it 'calls a proc exactly once if provided' do it 'calls a proc exactly once if provided' do
lazy = build_template(-> { 'bar' }) content_proc = -> { 'bar' }
content = lazy.content expect(content_proc).to receive(:call).once.and_call_original
expect(content).to eq('bar') lazy = build_template(content_proc)
expect(content.object_id).to eq(lazy.content.object_id)
content.replace('foo') expect(lazy.content).to eq('bar')
expect(lazy.content).to eq('foo')
# Subsequent calls should not call proc again
expect(lazy.content).to eq('bar')
end end
it 'returns a string if provided' do it 'returns a string if provided' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment