Sha256: e40f4d081cd757d45d7ae7dd3ab0388ec5765672770d93ff7c4ae294e7cd10e1

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:described_class) { Class.new(Function) { include Function::Binary } }
  let(:left)            { double('Left').freeze                            }
  let(:right)           { double('Right').freeze                           }
  let(:object)          { described_class.new(left, right)                 }

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

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

      def self.inverse
        InverseClass
      end

      def inspect
        'Binary::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(:left)  { should be(left)  }
  its(:right) { should be(right) }
end

Version data entries

2 entries across 2 versions & 1 rubygems

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