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-2.1.1 spec/integration/readme/my_model_spec.rb
sinclair-2.1.0 spec/integration/readme/my_model_spec.rb
sinclair-2.0.1 spec/integration/readme/my_model_spec.rb
sinclair-2.0.0 spec/integration/readme/my_model_spec.rb
sinclair-1.16.3 spec/integration/readme/my_model_spec.rb
sinclair-1.16.2 spec/integration/readme/my_model_spec.rb
sinclair-1.16.1 spec/integration/readme/my_model_spec.rb
sinclair-1.16.0 spec/integration/readme/my_model_spec.rb
sinclair-1.15.0 spec/integration/readme/my_model_spec.rb
sinclair-1.14.2 spec/integration/readme/my_model_spec.rb
sinclair-1.14.1 spec/integration/readme/my_model_spec.rb
sinclair-1.14.0 spec/integration/readme/my_model_spec.rb
sinclair-1.13.0 spec/integration/readme/my_model_spec.rb
sinclair-1.12.1 spec/integration/readme/my_model_spec.rb
sinclair-1.12.0 spec/integration/readme/my_model_spec.rb
sinclair-1.11.0 spec/integration/readme/my_model_spec.rb
sinclair-1.10.0 spec/integration/readme/my_model_spec.rb
sinclair-1.9.0 spec/integration/readme/my_model_spec.rb
sinclair-1.8.0 spec/integration/readme/my_model_spec.rb
sinclair-1.7.0 spec/integration/readme/my_model_spec.rb