Sha256: b244a7eaed6f880ed7319719a0e218d583de5e662f114fa65a23b6e81d8d9b50

Contents?: true

Size: 965 Bytes

Versions: 21

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

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

    it 'returns an change_instance_method_on' do
      expect(matcher.on(instance))
        .to eq(Sinclair::Matchers::ChangeInstanceMethodOn.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 changed on' \
          "change_method(:#{method}).on(instance)"
        )
    end
  end

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-2.1.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-2.0.1 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-2.0.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.16.3 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.16.2 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.16.1 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.16.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.15.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.14.2 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.14.1 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.14.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.13.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.12.1 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.12.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.11.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.10.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.9.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.8.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb
sinclair-1.7.0 spec/lib/sinclair/matchers/change_instance_method_spec.rb