-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a45c05a
commit 007f6f8
Showing
4 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'cuprum/collections/scopes' | ||
|
||
module Cuprum::Collections::Scopes | ||
# Functionality for implementing a scope container. | ||
module Container | ||
# @param scopes [Array<Scope>] the scopes wrapped by the scope. | ||
# @param options [Hash] additional options for the scope. | ||
def initialize(scopes:, **options) | ||
super(**options) | ||
|
||
@scopes = scopes | ||
end | ||
|
||
# @return [Array<Scope>] the scopes wrapped by the scope. | ||
attr_reader :scopes | ||
|
||
# Creates a copy of the scope with the given child scopes. | ||
# | ||
# @param scopes [Array] the child scopes. | ||
# | ||
# @return [Scope] the copied scope. | ||
def with_scopes(scopes) | ||
dup.tap { |copy| copy.scopes = scopes } | ||
end | ||
|
||
protected | ||
|
||
attr_writer :scopes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'cuprum/collections/scope' | ||
require 'cuprum/collections/scopes/container' | ||
require 'cuprum/collections/rspec/contracts/scope_contracts' | ||
|
||
RSpec.describe Cuprum::Collections::Scopes::Container do | ||
include Cuprum::Collections::RSpec::Contracts::ScopeContracts | ||
|
||
subject(:scope) { described_class.new(scopes: scopes) } | ||
|
||
let(:described_class) { Spec::ExampleScope } | ||
let(:scopes) { [] } | ||
|
||
example_class 'Spec::ExampleScope', Cuprum::Collections::Scope do |klass| | ||
klass.include Cuprum::Collections::Scopes::Container # rubocop:disable RSpec/DescribedClass | ||
end | ||
|
||
include_contract 'should be a container scope' | ||
end |