Sha256: f0a0cab456ac413a9fa99e41c3cacdcfeb130ff11b3aec76c55835b403d72bad

Contents?: true

Size: 740 Bytes

Versions: 5

Compression:

Stored size: 740 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Memoizable::MethodBuilder, '#original_method' do
  subject { object.original_method }

  let(:object)      { described_class.new(descendant, method_name, freezer) }
  let(:method_name) { :foo                                                  }
  let(:freezer)     { lambda { |object| object.freeze }                     }

  let(:descendant) do
    Class.new do
      def initialize
        @foo = 0
      end

      def foo
        @foo += 1
      end
    end
  end

  it { should be_instance_of(UnboundMethod) }

  it 'returns the original method' do
    # original method is not memoized
    method = subject.bind(descendant.new)
    expect(method.call).to_not be(method.call)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
memoizable-0.4.2 spec/unit/memoizable/method_builder/original_method_spec.rb
memoizable-0.4.1 spec/unit/memoizable/method_builder/original_method_spec.rb
memoizable-0.4.0 spec/unit/memoizable/method_builder/original_method_spec.rb
memoizable-0.3.1 spec/unit/memoizable/method_builder/original_method_spec.rb
memoizable-0.3.0 spec/unit/memoizable/method_builder/original_method_spec.rb