Module: Cuprum::Collections::RSpec::Contracts::Scopes::LogicalContracts::ShouldBeADisjunctionScopeContract 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 OR 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.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/cuprum/collections/rspec/contracts/scopes/logical_contracts.rb', line 97

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

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

  include_contract 'should compose scopes for disjunction'

  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 or'
  end

  describe '#invert' do
    let(:expected) do
      Cuprum::Collections::Scopes::ConjunctionScope.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, :disjunction
  end
end