Sha256: 4c87b702c6f291721865b092d492a64fe898e6b65ac5522391a7935237d601a9

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::Matchers::AddMethod do
  subject { described_class.new(method) }

  let(:method)   { :the_method }
  let(:klass)    { Class.new }
  let(:instance) { klass.new }

  describe '#to' do
    it do
      expect(subject.to(klass.new)).to be_a(Sinclair::Matchers::AddMethodTo)
    end

    it 'returns an add_method_to' do
      expect(subject.to(instance)).to eq(Sinclair::Matchers::AddMethodTo.new(instance, method))
    end
  end

  describe '#matches?' do
    it do
      expect do
        subject.matches?(proc {})
      end.to raise_error(
        SyntaxError, 'You should specify which instance the method is being added to' \
          "add_method(:#{method}).to(instance)"
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinclair-1.1.3 spec/lib/sinclair/matchers/add_method_spec.rb
sinclair-1.1.2 spec/lib/sinclair/matchers/add_method_spec.rb