Module: Cuprum::Collections::RSpec::Contracts::Scopes::LogicalContracts::ShouldBeAConjunctionScopeContract Deprecated

Extended by:
RSpec::SleepingKingStudios::Contract
Defined in:
lib/cuprum/collections/rspec/contracts/scopes/logical_contracts.rb

Overview

Deprecated.

0.6.0

Contract validating the behavior of a logical AND scope implementation.

Instance Method Summary collapse

Instance Method Details

#apply(example_group, abstract: false) ⇒ Object

Adds the contract to the example group.

Parameters:

  • example_group (RSpec::Core::ExampleGroup)

    the example group to which the contract is applied.

  • abstract (Boolean) (defaults to: false)

    if true, the scope is abstract and does not define a #call implementation. Defaults to false.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cuprum/collections/rspec/contracts/scopes/logical_contracts.rb', line 27

contract do |abstract: false|
  message =
    'Use deferred examples "should implement the ConjunctionScope ' \
    'methods"'
  SleepingKingStudios::Tools::Toolbelt
    .instance
    .core_tools
    .deprecate(
      'ShouldBeAConjunctionScopeContract',
      message:
    )

  include_contract 'should be a container scope', invertible: true

  include_contract 'should compose scopes for conjunction'

  describe '#as_json' do
    let(:expected) do
      {
        'scopes' => subject.scopes.map(&:as_json),
        'type'   => subject.type
      }
    end

    it { expect(subject.as_json).to be == expected }

    wrap_context 'with scopes' do
      it { expect(subject.as_json).to be == expected }
    end
  end

  describe '#call' do
    next if abstract

    include_contract 'should filter data by logical and'
  end

  describe '#invert' do
    let(:expected) do
      Cuprum::Collections::Scopes::DisjunctionScope.new(
        scopes: subject.scopes.map(&:invert)
      )
    end

    it { expect(subject.invert).to be == expected }

    wrap_context 'with scopes' do
      it { expect(subject.invert).to be == expected }
    end
  end

  describe '#type' do
    include_examples 'should define reader', :type, :conjunction
  end
end