Sha256: 6df840a381a52cf678eb44676c44bc00b8abbe5e6f7c41102f22eb27dc355630

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

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.1 spec/lib/sinclair/matchers/add_method_spec.rb
sinclair-1.1.0 spec/lib/sinclair/matchers/add_method_spec.rb