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'
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
......
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