Sha256: 484a95ace821d1ab53db1ab1cba40724bd47d303c6044c55fb7b95d7286b3fee
Contents?: true
Size: 578 Bytes
Versions: 41
Compression:
Stored size: 578 Bytes
Contents
# frozen_string_literal: true require 'spec_helper' describe MyModel do subject(:model) { klass.new } let(:klass) { Class.new(described_class) } let(:builder) { Sinclair.new(klass) } before do klass.send(:attr_accessor, :base, :expoent) builder.add_method(:cached_power, cached: true) do base**expoent end builder.build model.base = 3 model.expoent = 2 end it 'caches the result of the method' do expect { model.expoent = 3 } .not_to change(model, :cached_power) expect(model.cached_power).to eq(9) end end
Version data entries
41 entries across 41 versions & 1 rubygems
Version | Path |
---|---|
sinclair-1.2.0 | spec/integration/readme/my_model_spec.rb |