File: freeze_spec.rb

package info (click to toggle)
ruby-memoizable 0.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: ruby: 605; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# encoding: utf-8

require 'spec_helper'
require File.expand_path('../../fixtures/classes', __FILE__)

describe Memoizable::InstanceMethods, '#freeze' do
  subject { object.freeze }

  let(:described_class) { Class.new(Fixture::Object) }

  before do
    described_class.memoize(:test)
  end

  let(:object) { described_class.allocate }

  it_should_behave_like 'a command method'

  it 'freezes the object' do
    expect { subject }.to change(object, :frozen?).from(false).to(true)
  end

  it 'allows methods not yet called to be memoized' do
    subject
    expect(object.test).to be(object.test)
  end
end