Sha256: ff8b6d2f74a7c880f75e58e9173c02a2e60dc8164ff261d7f4664ceec43160a8

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

require 'unit_spec_helper'

describe Shoulda::Matchers::Independent::DelegateMethodMatcher::StubbedTarget do
  subject(:target) { described_class.new(:stubbed_method) }

  describe '#has_received_method?' do
    it 'returns true when the method has been called on the target' do
      target.stubbed_method

      expect(target).to have_received_method
    end

    it 'returns false when the method has not been called on the target' do
      expect(target).not_to have_received_method
    end
  end

  describe '#has_received_arguments?' do
    context 'method is called with specified arguments' do
      it 'returns true' do
        target.stubbed_method(:arg1, :arg2)

        expect(target).to have_received_arguments(:arg1, :arg2)
      end
    end

    context 'method is not called with specified arguments' do
      it 'returns false' do
        target.stubbed_method

        expect(target).not_to have_received_arguments(:arg1)
      end
    end

    context 'method is called with arguments in incorrect order' do
      it 'returns false' do
        target.stubbed_method(:arg2, :arg1)

        expect(target).not_to have_received_arguments(:arg1, :arg2)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
shoulda-matchers-3.1.3 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-4.0.0.rc1 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.1.2 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.1.1 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.1.0 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.0.1 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.0.0 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-3.0.0.rc1 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-2.8.0 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-2.8.0.rc2 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
shoulda-matchers-2.8.0.rc1 spec/unit/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb