Sha256: 998269a884a37e1881db9c1ab83854a4990f430714dfd280b5e427bd8a163771

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Function::Unary::Invertible, '#inverse' do
  subject { object.inverse }

  let(:described_class) { Class.new(Function) { include Function::Unary } }
  let(:operand)         { double('Operand').freeze                        }
  let(:object)          { described_class.new(operand)                    }

  let(:inverse_class) do
    Class.new(Function) do
      include Function::Unary::Invertible, Function::Unary
    end
  end

  before do
    described_class.class_eval do
      include Function::Unary::Invertible

      def self.inverse
        InverseClass
      end

      def inspect
        'Unary::Invertible'
      end
    end
  end

  before do
    ::InverseClass = inverse_class
  end

  after do
    Object.send(:remove_const, :InverseClass) if defined?(InverseClass)
  end

  it_should_behave_like 'an invertible method'

  it { should be_instance_of(InverseClass) }

  its(:operand) { should be(operand) }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/function/unary/invertible/inverse_spec.rb
axiom-0.1.1 spec/unit/axiom/function/unary/invertible/inverse_spec.rb