Module: Cuprum::Collections::RSpec::Contracts::Scopes::CompositionContracts::ShouldComposeScopesForDisjunctionContract Deprecated
- Extended by:
- RSpec::SleepingKingStudios::Contract
- Defined in:
- lib/cuprum/collections/rspec/contracts/scopes/composition_contracts.rb
Overview
Deprecated.
0.6.0
Contract validating scope composition for disjunction scopes.
Instance Method Summary collapse
-
#apply(example_group) ⇒ Object
Adds the contract to the example group.
Instance Method Details
#apply(example_group) ⇒ Object
Adds the contract to the example group.
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 |
# File 'lib/cuprum/collections/rspec/contracts/scopes/composition_contracts.rb', line 1339 contract do shared_context 'when the scope has many child scopes' do let(:scopes) do [ build_scope({ 'author' => 'J.R.R. Tolkien' }), build_scope({ 'series' => 'The Lord of the Rings' }), build_scope do |scope| { 'published_at' => scope.less_than('1955-01-01') } end ] end end include_contract 'should compose scopes', except: %i[or] describe '#or' do describe 'with a block' do let(:block) { -> { { 'title' => 'A Wizard of Earthsea' } } } let(:expected) do wrapped = Cuprum::Collections::Scope.new(&block) Cuprum::Collections::Scopes::DisjunctionScope.new( scopes: [*subject.scopes, wrapped] ) end it { expect(subject.or(&block)).to be == expected } end describe 'with a hash' do let(:value) { { 'title' => 'A Wizard of Earthsea' } } let(:expected) do wrapped = Cuprum::Collections::Scope.new(value) Cuprum::Collections::Scopes::DisjunctionScope.new( scopes: [*subject.scopes, wrapped] ) end it { expect(subject.or(value)).to be == expected } end wrap_context 'with an all scope' do it { expect(subject.or(original)).to be == original } end wrap_context 'with a none scope' do it { expect(subject.or(original)).to be subject } end wrap_context 'with an empty conjunction scope' do it { expect(subject.or(original)).to be subject } end wrap_context 'with an empty criteria scope' do it { expect(subject.or(original)).to be subject } end wrap_context 'with an empty disjunction scope' do it { expect(subject.or(original)).to be subject } end wrap_context 'with a non-empty conjunction scope' do let(:expected) do Cuprum::Collections::Scopes::DisjunctionScope.new( scopes: [*subject.scopes, original] ) end it { expect(subject.or(original)).to be == expected } end wrap_context 'with a non-empty criteria scope' do let(:expected) do Cuprum::Collections::Scopes::DisjunctionScope.new( scopes: [*subject.scopes, original] ) end it { expect(subject.or(original)).to be == expected } end wrap_context 'with a non-empty disjunction scope' do let(:expected) do Cuprum::Collections::Scopes::DisjunctionScope.new( scopes: [*subject.scopes, *original.scopes] ) end it { expect(subject.or(original)).to be == expected } wrap_context 'when the scope has many child scopes' do it { expect(subject.or(original)).to be == expected } end end end end |