Sha256: e3cd838b0a04e8b124f2ffa571cbcf5e5ea7b18498bce2b1a78f7c9be83a6216

Contents?: true

Size: 948 Bytes

Versions: 32

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

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

    it 'returns an add_instance_method_to' do
      expect(matcher.to(instance))
        .to eq(Sinclair::Matchers::AddInstanceMethodTo.new(instance, method))
    end
  end

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

  describe '#supports_block_expectations?' do
    it do
      expect(matcher).to be_supports_block_expectations
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
sinclair-1.6.7 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.6 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.5 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.4 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.3 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.2 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.1 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.6.0 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.5.2 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.5.1 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.5.0 spec/lib/sinclair/matchers/add_instance_method_spec.rb
sinclair-1.4.2 spec/lib/sinclair/matchers/add_instance_method_spec.rb