diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30195353..6a9c1cc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,8 @@
### Changed
+- Transform `BCDD::Result::Context` into `BCDD::Context`. But a constant alias was added to keep the old name. You can use `BCDD::Result::Context` or `BCDD::Context` to access the same class.
+
- **(BREAKING)** Replace trasitions metadata `:ids_tree`, and `:ids_matrix` with `:ids` property. This property is a hash with the following keys:
- `:tree`, a graph/tree representation of the transitions ids.
- `:level_parent`, a hash with the level (depth) of each transition and its parent id.
diff --git a/README.md b/README.md
index 004196ad..2f31e6f7 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
🔀 BCDD::Result
Unleash a pragmatic and observable use of Result Pattern and Railway-Oriented Programming in Ruby.
-
+
@@ -19,7 +19,7 @@ Furthermore, this abstraction exposes several features that will be useful to ma
Use it to enable the [Railway Oriented Programming](https://fsharpforfunandprofit.com/rop/) pattern (superpower) in your code.
-- [Ruby Version](#ruby-version)
+- [Supported Ruby](#supported-ruby)
- [Installation](#installation)
- [Usage](#usage)
- [`BCDD::Result` *versus* `Result`](#bcddresult-versus-result)
@@ -63,14 +63,14 @@ Use it to enable the [Railway Oriented Programming](https://fsharpforfunandprofi
- [Failure()](#failure)
- [Pattern Matching Support](#pattern-matching-support)
- [`BCDD::Result::Expectations.mixin` add-ons](#bcddresultexpectationsmixin-add-ons)
- - [`BCDD::Result::Context`](#bcddresultcontext)
+ - [`BCDD::Context`](#bcddcontext)
- [Defining successes and failures](#defining-successes-and-failures)
- [Constant aliases](#constant-aliases)
- - [`BCDD::Result::Context.mixin`](#bcddresultcontextmixin)
+ - [`BCDD::Context.mixin`](#bcddcontextmixin)
- [Class example (Instance Methods)](#class-example-instance-methods-1)
- [`and_expose`](#and_expose)
- [Module example (Singleton Methods)](#module-example-singleton-methods-1)
- - [`BCDD::Result::Context::Expectations`](#bcddresultcontextexpectations)
+ - [`BCDD::Context::Expectations`](#bcddcontextexpectations)
- [Mixin add-ons](#mixin-add-ons)
- [`BCDD::Result.transitions`](#bcddresulttransitions)
- [`metadata: {ids:}`](#metadata-ids)
@@ -93,9 +93,13 @@ Use it to enable the [Railway Oriented Programming](https://fsharpforfunandprofi
- [License](#license)
- [Code of Conduct](#code-of-conduct)
-## Ruby Version
+## Supported Ruby
-`>= 2.7.0`
+This library is tested against:
+
+Version | 2.7 | 3.0 | 3.1 | 3.2 | 3.3 | Head
+---- | --- | --- | --- | --- | --- | ---
+100% Coverage | ✅ | ✅ | ✅ | ✅ | ✅ | ✅
## Installation
@@ -1429,45 +1433,45 @@ result.success?(:ok)
⬆️ back to top
-### `BCDD::Result::Context`
+### `BCDD::Context`
-The `BCDD::Result::Context` is a `BCDD::Result`, meaning it has all the features of the `BCDD::Result`. The main difference is that it only accepts keyword arguments as a value, which applies to the `and_then`: The called methods must receive keyword arguments, and the dependency injection will be performed through keyword arguments.
+The `BCDD::Context` is a `BCDD::Result`, meaning it has all the features of the `BCDD::Result`. The main difference is that it only accepts keyword arguments as a value, which applies to the `and_then`: The called methods must receive keyword arguments, and the dependency injection will be performed through keyword arguments.
-As the input/output are hashes, the results of each `and_then` call will automatically accumulate. This is useful in operations chaining, as the result of the previous operations will be automatically available for the next one. Because of this behavior, the `BCDD::Result::Context` has the `#and_expose` method to expose only the desired keys from the accumulated result.
+As the input/output are hashes, the results of each `and_then` call will automatically accumulate. This is useful in operations chaining, as the result of the previous operations will be automatically available for the next one. Because of this behavior, the `BCDD::Context` has the `#and_expose` method to expose only the desired keys from the accumulated result.
#### Defining successes and failures
-As the `BCDD::Result`, you can declare success and failures directly from `BCDD::Result::Context`.
+As the `BCDD::Result`, you can declare success and failures directly from `BCDD::Context`.
```ruby
-BCDD::Result::Context::Success(:ok, a: 1, b: 2)
-#1, :b=>2}>
+BCDD::Context::Success(:ok, a: 1, b: 2)
+#1, :b=>2}>
-BCDD::Result::Context::Failure(:err, message: 'something went wrong')
-#"something went wrong"}>
+BCDD::Context::Failure(:err, message: 'something went wrong')
+#"something went wrong"}>
```
-But different from `BCDD::Result` that accepts any value, the `BCDD::Result::Context` only takes keyword arguments.
+But different from `BCDD::Result` that accepts any value, the `BCDD::Context` only takes keyword arguments.
```ruby
-BCDD::Result::Context::Success(:ok, [1, 2])
+BCDD::Context::Success(:ok, [1, 2])
# wrong number of arguments (given 2, expected 1) (ArgumentError)
-BCDD::Result::Context::Failure(:err, { message: 'something went wrong' })
+BCDD::Context::Failure(:err, { message: 'something went wrong' })
# wrong number of arguments (given 2, expected 1) (ArgumentError)
#
# Use ** to convert a hash to keyword arguments
#
-BCDD::Result::Context::Success(:ok, **{ message: 'hashes can be converted to keyword arguments' })
-#"hashes can be converted to keyword arguments"}>
+BCDD::Context::Success(:ok, **{ message: 'hashes can be converted to keyword arguments' })
+#"hashes can be converted to keyword arguments"}>
```
⬆️ back to top
#### Constant aliases
-You can configure `Context` or `BCDD::Context` as an alias for `BCDD::Result::Context`. This is helpful to define a standard way to avoid the full constant name/path in your code.
+You can configure `Context` or `BCDD::Context` as an alias for `BCDD::Context`. This is helpful to define a standard way to avoid the full constant name/path in your code.
```ruby
BCDD::Result.configuration do |config|
@@ -1481,9 +1485,9 @@ end
⬆️ back to top
-#### `BCDD::Result::Context.mixin`
+#### `BCDD::Context.mixin`
-As in the `BCDD::Result`, you can use the `BCDD::Result::Context.mixin` to add the `Success()` and `Failure()` methods to your classes/modules.
+As in the `BCDD::Result`, you can use the `BCDD::Context.mixin` to add the `Success()` and `Failure()` methods to your classes/modules.
Let's see this feature and the data accumulation in action:
@@ -1493,7 +1497,7 @@ Let's see this feature and the data accumulation in action:
require 'logger'
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2, logger: ::Logger.new(STDOUT))
validate_numbers(arg1, arg2)
@@ -1530,29 +1534,29 @@ end
Divide.new.call(10, 5)
# I, [2023-10-27T01:51:46.905004 #76915] INFO -- : The division result is 2
-#2}>
+#2}>
Divide.new.call('10', 5)
-#"arg1 must be numeric"}>
+#"arg1 must be numeric"}>
Divide.new.call(10, '5')
-#"arg2 must be numeric"}>
+#"arg2 must be numeric"}>
Divide.new.call(10, 0)
-#"arg2 must not be zero"}>
+#"arg2 must not be zero"}>
```
⬆️ back to top
##### `and_expose`
-This allows you to expose only the desired keys from the accumulated result. It can be used with any `BCDD::Result::Context` object.
+This allows you to expose only the desired keys from the accumulated result. It can be used with any `BCDD::Context` object.
Let's add it to the previous example:
```ruby
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
@@ -1582,7 +1586,7 @@ class Divide
end
Divide.new.call(10, 5)
-#2}>
+#2}>
```
As you can see, even with `divide` success exposing the division number with all the accumulated data (`**input`), the `#and_expose` could generate a new success with a new type and only with the desired keys.
@@ -1591,7 +1595,7 @@ Remove the `#and_expose` call to see the difference. This will be the outcome:
```ruby
Divide.new.call(10, 5)
-#2, :number1=>10, :number2=>5}>
+#2, :number1=>10, :number2=>5}>
```
> PS: The `#and_expose` produces a terminal success by default. This means the next step will not be executed even if you call `#and_then` after `#and_expose`. To change this behavior, you can pass `terminal: false` to `#and_expose`.
@@ -1600,11 +1604,11 @@ Divide.new.call(10, 5)
##### Module example (Singleton Methods)
-`BCDD::Result::Context.mixin` can also produce singleton methods. Below is an example using a module (but it could be a class, too).
+`BCDD::Context.mixin` can also produce singleton methods. Below is an example using a module (but it could be a class, too).
```ruby
module Divide
- extend self, BCDD::Result::Context.mixin
+ extend self, BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
@@ -1634,29 +1638,29 @@ module Divide
end
Divide.call(10, 5)
-#2}>
+#2}>
Divide.call('10', 5)
-#"arg1 must be numeric"}>
+#"arg1 must be numeric"}>
Divide.call(10, '5')
-#"arg2 must be numeric"}>
+#"arg2 must be numeric"}>
Divide.call(10, 0)
-#"arg2 must not be zero"}>
+#"arg2 must not be zero"}>
```
⬆️ back to top
-#### `BCDD::Result::Context::Expectations`
+#### `BCDD::Context::Expectations`
-The `BCDD::Result::Context::Expectations` is a `BCDD::Result::Expectations` with the `BCDD::Result::Context` features.
+The `BCDD::Context::Expectations` is a `BCDD::Result::Expectations` with the `BCDD::Context` features.
This is an example using the mixin mode, but the standalone mode is also supported.
```ruby
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: {
pattern_matching: { nil_as_valid_value_checking: true }
},
@@ -1680,16 +1684,16 @@ class Divide
end
Divide.new.call(10, 5)
-#2}>
+#2}>
```
-As in the `BCDD::Result::Expectations.mixin`, the `BCDD::Result::Context::Expectations.mixin` will add a Result constant in the target class. It can generate success/failure results, which ensure the mixin expectations.
+As in the `BCDD::Result::Expectations.mixin`, the `BCDD::Context::Expectations.mixin` will add a Result constant in the target class. It can generate success/failure results, which ensure the mixin expectations.
Let's see this using the previous example:
```ruby
Divide::Result::Success(:division_completed, number: 2)
-#2}>
+#2}>
Divide::Result::Success(:division_completed, number: '2')
# value {:number=>"2"} is not allowed for :division_completed type ({:number=>"2"}: Numeric === "2" does not return true) (BCDD::Result::Contract::Error::UnexpectedValue)
@@ -1699,7 +1703,7 @@ Divide::Result::Success(:division_completed, number: '2')
#### Mixin add-ons
-The `BCDD::Result::Context.mixin` and `BCDD::Result::Context::Expectations.mixin` also accepts the `config:` argument. And it works the same way as the `BCDD::Result` mixins.
+The `BCDD::Context.mixin` and `BCDD::Context::Expectations.mixin` also accepts the `config:` argument. And it works the same way as the `BCDD::Result` mixins.
**given**
@@ -1707,21 +1711,21 @@ This addon is enabled by default. It will create the `Given(*value)` method. Use
You can turn it off by passing `given: false` to the `config:` argument or using the `BCDD::Result.configuration`.
-The `Given()` addon for a BCDD::Result::Context can be called with one or more arguments. The arguments will be converted to a hash (`to_h`) and merged to define the first value of the result chain.
+The `Given()` addon for a BCDD::Context can be called with one or more arguments. The arguments will be converted to a hash (`to_h`) and merged to define the first value of the result chain.
**continue**
-The `BCDD::Result::Context.mixin(config: { addon: { continue: true } })` or `BCDD::Result::Context::Expectations.mixin(config: { addon: { continue: true } })` creates the `Continue(value)` method and change the `Success()` behavior to terminate the step chain.
+The `BCDD::Context.mixin(config: { addon: { continue: true } })` or `BCDD::Context::Expectations.mixin(config: { addon: { continue: true } })` creates the `Continue(value)` method and change the `Success()` behavior to terminate the step chain.
So, if you want to advance to the next step, you must use `Continue(**value)` instead of `Success(type, **value)`. Otherwise, the step chain will be terminated.
-Let's use a mix of `BCDD::Result::Context` features to see in action with this add-on:
+Let's use a mix of `BCDD::Context` features to see in action with this add-on:
```ruby
module Division
require 'logger'
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: {
addon: { continue: true },
pattern_matching: { nil_as_valid_value_checking: true }
@@ -1771,26 +1775,26 @@ end
Division.call(14, 2)
# I, [2023-10-27T02:01:05.812388 #77823] INFO -- : The division result is 7
-#7}>
+#7}>
Division.call(0, 2)
-##0}>
+##0}>
Division.call('14', 2)
-#"arg1 must be numeric"}>
+#"arg1 must be numeric"}>
Division.call(14, '2')
-#"arg2 must be numeric"}>
+#"arg2 must be numeric"}>
Division.call(14, 0)
-#"arg2 must not be zero"}>
+#"arg2 must not be zero"}>
```
⬆️ back to top
## `BCDD::Result.transitions`
-Use `BCDD::Result.transitions(&block)` to track all transitions in the same or between different operations (it works with `BCDD::Result` and `BCDD::Result::Context`). When there is a nesting of transition blocks, this mechanism will be able to correlate parent and child blocks and present the duration of all operations in milliseconds.
+Use `BCDD::Result.transitions(&block)` to track all transitions in the same or between different operations (it works with `BCDD::Result` and `BCDD::Context`). When there is a nesting of transition blocks, this mechanism will be able to correlate parent and child blocks and present the duration of all operations in milliseconds.
When you wrap the creation of the result with `BCDD::Result.transitions`, the final result will expose all the transition records through the `BCDD::Result#transitions` method.
@@ -2196,7 +2200,7 @@ BCDD::Result.config.transitions.listener = BCDD::Result::Transitions::Listeners[
## `BCDD::Result.configuration`
-The `BCDD::Result.configuration` allows you to configure default behaviors for `BCDD::Result` and `BCDD::Result::Context` through a configuration block. After using it, the configuration is frozen, ensuring the expected behaviors for your application.
+The `BCDD::Result.configuration` allows you to configure default behaviors for `BCDD::Result` and `BCDD::Context` through a configuration block. After using it, the configuration is frozen, ensuring the expected behaviors for your application.
> Note: You can use `BCDD::Result.configuration(freeze: false) {}` to avoid the freezing. This can be useful in tests. Please be sure to use it with caution.
@@ -2218,13 +2222,13 @@ Let's see what each configuration in the example above does:
### `config.addon.enable!(:given, :continue)`
-This configuration enables the `Continue()` method for `BCDD::Result.mixin`, `BCDD::Result::Context.mixin`, `BCDD::Result::Expectation.mixin`, and `BCDD::Result::Context::Expectation.mixin`. Link to documentations: [(1)](#add-ons) [(2)](#mixin-add-ons).
+This configuration enables the `Continue()` method for `BCDD::Result.mixin`, `BCDD::Context.mixin`, `BCDD::Result::Expectation.mixin`, and `BCDD::Context::Expectation.mixin`. Link to documentations: [(1)](#add-ons) [(2)](#mixin-add-ons).
It is also enabling the `Given()` which is already enabled by default. Link to documentation: [(1)](#add-ons) [(2)](#mixin-add-ons).
### `config.constant_alias.enable!('Result', 'BCDD::Context')`
-This configuration make `Result` a constant alias for `BCDD::Result`, and `BCDD::Context` a constant alias for `BCDD::Result::Context`.
+This configuration make `Result` a constant alias for `BCDD::Result`, and `BCDD::Context` a constant alias for `BCDD::Context`.
Link to documentations:
- [Result alias](#bcddresult-versus-result)
@@ -2232,11 +2236,11 @@ Link to documentations:
### `config.pattern_matching.disable!(:nil_as_valid_value_checking)`
-This configuration disables the `nil_as_valid_value_checking` for `BCDD::Result` and `BCDD::Result::Context`. Link to [documentation](#pattern-matching-support).
+This configuration disables the `nil_as_valid_value_checking` for `BCDD::Result` and `BCDD::Context`. Link to [documentation](#pattern-matching-support).
### `config.feature.disable!(:expectations)`
-This configuration turns off the expectations for `BCDD::Result` and `BCDD::Result::Context`. The expectations are helpful in development and test environments, but they can be disabled in production environments for performance gain.
+This configuration turns off the expectations for `BCDD::Result` and `BCDD::Context`. The expectations are helpful in development and test environments, but they can be disabled in production environments for performance gain.
PS: I'm using `::Rails.env.production?` to check the environment, but you can use any logic you want.
@@ -2258,18 +2262,18 @@ BCDD::Result.config.addon.options
# :enabled=>false,
# :affects=>[
# "BCDD::Result.mixin",
-# "BCDD::Result::Context.mixin",
+# "BCDD::Context.mixin",
# "BCDD::Result::Expectations.mixin",
-# "BCDD::Result::Context::Expectations.mixin"
+# "BCDD::Context::Expectations.mixin"
# ]
# },
# :given=>{
# :enabled=>true,
# :affects=>[
# "BCDD::Result.mixin",
-# "BCDD::Result::Context.mixin",
+# "BCDD::Context.mixin",
# "BCDD::Result::Expectations.mixin",
-# "BCDD::Result::Context::Expectations.mixin"
+# "BCDD::Context::Expectations.mixin"
# ]
# }
# }
@@ -2301,7 +2305,7 @@ BCDD::Result.config.pattern_matching.options
# :enabled=>false,
# :affects=>[
# "BCDD::Result::Expectations,
-# "BCDD::Result::Context::Expectations"
+# "BCDD::Context::Expectations"
# ]
# }
# }
@@ -2318,21 +2322,21 @@ BCDD::Result.config.feature.options
# :enabled=>true,
# :affects=>[
# "BCDD::Result::Expectations,
-# "BCDD::Result::Context::Expectations"
+# "BCDD::Context::Expectations"
# ]
# },
# :transitions=>{
# :enabled=>true,
# :affects=>[
# "BCDD::Result",
-# "BCDD::Result::Context"
+# "BCDD::Context"
# ]
# },
# :and_then!=>{
# :enabled=>false,
# :affects=>[
# "BCDD::Result",
-# "BCDD::Result::Context"
+# "BCDD::Context"
# ]
# },
# }
@@ -2375,7 +2379,7 @@ class PlaceOrder < Micro::Case
end
```
-To facilitate migration for users accustomed to the above approaches, `bcdd-result` includes the `BCDD::Result#and_then!`/`BCDD::Result::Context#and_then!` methods, which will invoke the method `call` of the given operation and expect it to return a `BCDD::Result`/`BCDD::Result::Context` object.
+To facilitate migration for users accustomed to the above approaches, `bcdd-result` includes the `BCDD::Result#and_then!`/`BCDD::Context#and_then!` methods, which will invoke the method `call` of the given operation and expect it to return a `BCDD::Result`/`BCDD::Context` object.
```ruby
BCDD::Result.configure do |config|
@@ -2383,7 +2387,7 @@ BCDD::Result.configure do |config|
end
class PlaceOrder
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(**input)
Given(input)
@@ -2415,11 +2419,11 @@ class PlaceOrder
end
```
-**In BCDD::Result::Context**
+**In BCDD::Context**
```ruby
class PlaceOrder
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(logger:, **input)
Given(input)
@@ -2473,7 +2477,7 @@ Attention: to ensure the correct behavior, do not mix `#and_then` and `#and_then
#### Analysis: Why is `#and_then` the antidote/standard?
-The `BCDD::Result#and_then`/`BCDD::Result::Context#and_then` methods diverge from the above approach by requiring explicit invocation and mapping of the outcomes at each process step. This approach has the following advantages:
+The `BCDD::Result#and_then`/`BCDD::Context#and_then` methods diverge from the above approach by requiring explicit invocation and mapping of the outcomes at each process step. This approach has the following advantages:
- **Clarity:** The input/output relationship between the steps is apparent and highly understandable.
@@ -2483,7 +2487,7 @@ See this example to understand what your code should look like:
```ruby
class PlaceOrder
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call(**input)
Given(input)
diff --git a/examples/multiple_listeners/config/initializers/bcdd.rb b/examples/multiple_listeners/config/initializers/bcdd.rb
index f0caa1a2..e03924b3 100644
--- a/examples/multiple_listeners/config/initializers/bcdd.rb
+++ b/examples/multiple_listeners/config/initializers/bcdd.rb
@@ -3,8 +3,6 @@
BCDD::Result.config.then do |config|
config.addon.enable!(:continue)
- config.constant_alias.enable!('BCDD::Context')
-
config.pattern_matching.disable!(:nil_as_valid_value_checking)
# config.feature.disable!(:expectations) if Rails.env.production?
diff --git a/examples/service_objects/app/services/application_service.rb b/examples/service_objects/app/services/application_service.rb
index 5d7de67d..b418dd38 100644
--- a/examples/service_objects/app/services/application_service.rb
+++ b/examples/service_objects/app/services/application_service.rb
@@ -33,7 +33,7 @@ def input(&block)
end
def inherited(subclass)
- subclass.include ::BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ subclass.include ::BCDD::Context.mixin(config: { addon: { continue: true } })
end
def call(arg)
diff --git a/examples/service_objects/config/initializers/bcdd.rb b/examples/service_objects/config/initializers/bcdd.rb
index f0caa1a2..e03924b3 100644
--- a/examples/service_objects/config/initializers/bcdd.rb
+++ b/examples/service_objects/config/initializers/bcdd.rb
@@ -3,8 +3,6 @@
BCDD::Result.config.then do |config|
config.addon.enable!(:continue)
- config.constant_alias.enable!('BCDD::Context')
-
config.pattern_matching.disable!(:nil_as_valid_value_checking)
# config.feature.disable!(:expectations) if Rails.env.production?
diff --git a/examples/single_listener/config/initializers/bcdd.rb b/examples/single_listener/config/initializers/bcdd.rb
index f0caa1a2..e03924b3 100644
--- a/examples/single_listener/config/initializers/bcdd.rb
+++ b/examples/single_listener/config/initializers/bcdd.rb
@@ -3,8 +3,6 @@
BCDD::Result.config.then do |config|
config.addon.enable!(:continue)
- config.constant_alias.enable!('BCDD::Context')
-
config.pattern_matching.disable!(:nil_as_valid_value_checking)
# config.feature.disable!(:expectations) if Rails.env.production?
diff --git a/lib/bcdd/context.rb b/lib/bcdd/context.rb
new file mode 100644
index 00000000..a41fbfc8
--- /dev/null
+++ b/lib/bcdd/context.rb
@@ -0,0 +1,91 @@
+# frozen_string_literal: true
+
+class BCDD::Context < BCDD::Result
+ require_relative 'context/failure'
+ require_relative 'context/success'
+ require_relative 'context/mixin'
+ require_relative 'context/expectations'
+ require_relative 'context/callable_and_then'
+
+ EXPECTED_OUTCOME = 'BCDD::Context::Success or BCDD::Context::Failure'
+
+ def self.Success(type, **value)
+ Success.new(type: type, value: value)
+ end
+
+ def self.Failure(type, **value)
+ Failure.new(type: type, value: value)
+ end
+
+ def initialize(type:, value:, source: nil, expectations: nil, terminal: nil)
+ value.is_a?(::Hash) or raise ::ArgumentError, 'value must be a Hash'
+
+ @acc = {}
+
+ super
+ end
+
+ def and_then(method_name = nil, **injected_value, &block)
+ super(method_name, injected_value, &block)
+ end
+
+ def and_then!(source, **injected_value)
+ _call = injected_value.delete(:_call)
+
+ acc.merge!(injected_value)
+
+ super(source, injected_value, _call: _call)
+ end
+
+ protected
+
+ attr_reader :acc
+
+ private
+
+ SourceMethodArity = ->(method) do
+ return 0 if method.arity.zero?
+
+ parameters = method.parameters.map(&:first)
+
+ return 1 if !parameters.empty? && parameters.all?(/\Akey/)
+
+ -1
+ end
+
+ def call_and_then_source_method!(method, injected_value)
+ acc.merge!(value.merge(injected_value))
+
+ case SourceMethodArity[method]
+ when 0 then source.send(method.name)
+ when 1 then source.send(method.name, **acc)
+ else raise Error::InvalidSourceMethodArity.build(source: source, method: method, max_arity: 1)
+ end
+ end
+
+ def call_and_then_block!(block)
+ acc.merge!(value)
+
+ block.call(acc)
+ end
+
+ def call_and_then_callable!(source, value:, injected_value:, method_name:)
+ acc.merge!(value.merge(injected_value))
+
+ CallableAndThen::Caller.call(source, value: acc, injected_value: injected_value, method_name: method_name)
+ end
+
+ def ensure_result_object(result, origin:)
+ raise_unexpected_outcome_error(result, origin) unless result.is_a?(BCDD::Context)
+
+ return result.tap { _1.acc.merge!(acc) } if result.source.equal?(source)
+
+ raise Error::InvalidResultSource.build(given_result: result, expected_source: source)
+ end
+
+ def raise_unexpected_outcome_error(result, origin)
+ raise Error::UnexpectedOutcome.build(outcome: result, origin: origin, expected: EXPECTED_OUTCOME)
+ end
+
+ private_constant :SourceMethodArity
+end
diff --git a/lib/bcdd/result/context/callable_and_then.rb b/lib/bcdd/context/callable_and_then.rb
similarity index 73%
rename from lib/bcdd/result/context/callable_and_then.rb
rename to lib/bcdd/context/callable_and_then.rb
index 10fe897b..349baaf4 100644
--- a/lib/bcdd/result/context/callable_and_then.rb
+++ b/lib/bcdd/context/callable_and_then.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-class BCDD::Result
+module BCDD
module Context::CallableAndThen
- class Caller < CallableAndThen::Caller
+ class Caller < Result::CallableAndThen::Caller
module KeyArgs
def self.parameters?(source)
parameters = source.parameters.map(&:first)
@@ -11,7 +11,7 @@ def self.parameters?(source)
end
def self.invalid_arity(source, method)
- CallableAndThen::Error::InvalidArity.build(source: source, method: method, arity: 'only keyword args')
+ Result::CallableAndThen::Error::InvalidArity.build(source: source, method: method, arity: 'only keyword args')
end
end
@@ -30,7 +30,8 @@ def self.call_method!(source, method, value, _injected_value)
def self.ensure_result_object(source, value, result)
return result.tap { result.send(:acc).then { _1.merge!(value.merge(_1)) } } if result.is_a?(Context)
- raise Error::UnexpectedOutcome.build(outcome: result, origin: source, expected: Context::EXPECTED_OUTCOME)
+ raise Result::Error::UnexpectedOutcome.build(outcome: result, origin: source,
+ expected: Context::EXPECTED_OUTCOME)
end
private_class_method :call_proc!, :call_method!
diff --git a/lib/bcdd/result/context/expectations.rb b/lib/bcdd/context/expectations.rb
similarity index 89%
rename from lib/bcdd/result/context/expectations.rb
rename to lib/bcdd/context/expectations.rb
index ac4127f5..6d41e77d 100644
--- a/lib/bcdd/result/context/expectations.rb
+++ b/lib/bcdd/context/expectations.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class BCDD::Result::Context
+class BCDD::Context
class Expectations < BCDD::Result::Expectations
require_relative 'expectations/mixin'
@@ -9,7 +9,7 @@ def self.mixin_module
end
def self.result_factory_without_expectations
- ::BCDD::Result::Context
+ ::BCDD::Context
end
private_class_method :mixin!, :mixin_module, :result_factory_without_expectations
diff --git a/lib/bcdd/result/context/expectations/mixin.rb b/lib/bcdd/context/expectations/mixin.rb
similarity index 96%
rename from lib/bcdd/result/context/expectations/mixin.rb
rename to lib/bcdd/context/expectations/mixin.rb
index 1da62a21..7f9c8fb1 100644
--- a/lib/bcdd/result/context/expectations/mixin.rb
+++ b/lib/bcdd/context/expectations/mixin.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class BCDD::Result::Context
+class BCDD::Context
module Expectations::Mixin
Factory = BCDD::Result::Expectations::Mixin::Factory
diff --git a/lib/bcdd/result/context/failure.rb b/lib/bcdd/context/failure.rb
similarity index 68%
rename from lib/bcdd/result/context/failure.rb
rename to lib/bcdd/context/failure.rb
index f89b57bf..e1dc7497 100644
--- a/lib/bcdd/result/context/failure.rb
+++ b/lib/bcdd/context/failure.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class BCDD::Result::Context::Failure < BCDD::Result::Context
+class BCDD::Context::Failure < BCDD::Context
include BCDD::Result::Failure::Methods
def and_expose(_type, _keys, **_options)
diff --git a/lib/bcdd/result/context/mixin.rb b/lib/bcdd/context/mixin.rb
similarity index 95%
rename from lib/bcdd/result/context/mixin.rb
rename to lib/bcdd/context/mixin.rb
index 27e836cf..0113b91c 100644
--- a/lib/bcdd/result/context/mixin.rb
+++ b/lib/bcdd/context/mixin.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class BCDD::Result::Context
+class BCDD::Context
module Mixin
Factory = BCDD::Result::Mixin::Factory
@@ -50,7 +50,7 @@ def self.mixin_module
end
def self.result_factory
- ::BCDD::Result::Context
+ ::BCDD::Context
end
private_class_method :mixin_module, :result_factory
diff --git a/lib/bcdd/result/context/success.rb b/lib/bcdd/context/success.rb
similarity index 85%
rename from lib/bcdd/result/context/success.rb
rename to lib/bcdd/context/success.rb
index face55e3..a5e9ea67 100644
--- a/lib/bcdd/result/context/success.rb
+++ b/lib/bcdd/context/success.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-class BCDD::Result
- class Context::Error < BCDD::Result::Error
+class BCDD::Context
+ class Error < BCDD::Result::Error
InvalidExposure = ::Class.new(self)
end
- class Context::Success < Context
+ class Success < self
include ::BCDD::Result::Success::Methods
FetchValues = ->(acc_values, keys) do
@@ -15,7 +15,7 @@ class Context::Success < Context
rescue ::KeyError => e
message = "#{e.message}. Available to expose: #{acc_values.keys.map(&:inspect).join(', ')}"
- raise Context::Error::InvalidExposure, message
+ raise Error::InvalidExposure, message
end
def and_expose(type, keys, terminal: true)
diff --git a/lib/bcdd/result.rb b/lib/bcdd/result.rb
index 80360837..c561cfc7 100644
--- a/lib/bcdd/result.rb
+++ b/lib/bcdd/result.rb
@@ -15,8 +15,8 @@
require_relative 'result/mixin'
require_relative 'result/contract'
require_relative 'result/expectations'
-require_relative 'result/context'
require_relative 'result/config'
+require_relative 'result/context'
class BCDD::Result
attr_accessor :unknown, :transitions
diff --git a/lib/bcdd/result/config/switchers/addons.rb b/lib/bcdd/result/config/switchers/addons.rb
index 95416282..16c6c8c2 100644
--- a/lib/bcdd/result/config/switchers/addons.rb
+++ b/lib/bcdd/result/config/switchers/addons.rb
@@ -5,9 +5,9 @@ class Config
module Addons
AFFECTS = %w[
BCDD::Result.mixin
- BCDD::Result::Context.mixin
+ BCDD::Context.mixin
BCDD::Result::Expectations.mixin
- BCDD::Result::Context::Expectations.mixin
+ BCDD::Context::Expectations.mixin
].freeze
OPTIONS = {
diff --git a/lib/bcdd/result/config/switchers/constant_aliases.rb b/lib/bcdd/result/config/switchers/constant_aliases.rb
index 0677b16f..5ca7c6b7 100644
--- a/lib/bcdd/result/config/switchers/constant_aliases.rb
+++ b/lib/bcdd/result/config/switchers/constant_aliases.rb
@@ -4,9 +4,7 @@ class BCDD::Result
class Config
module ConstantAliases
MAPPING = {
- 'Result' => { target: ::Object, name: :Result, value: ::BCDD::Result },
- 'Context' => { target: ::Object, name: :Context, value: ::BCDD::Result::Context },
- 'BCDD::Context' => { target: ::BCDD, name: :Context, value: ::BCDD::Result::Context }
+ 'Result' => { target: ::Object, name: :Result, value: ::BCDD::Result }
}.transform_values!(&:freeze).freeze
OPTIONS = MAPPING.to_h do |option_name, mapping|
diff --git a/lib/bcdd/result/config/switchers/features.rb b/lib/bcdd/result/config/switchers/features.rb
index 4a342012..b7db49f3 100644
--- a/lib/bcdd/result/config/switchers/features.rb
+++ b/lib/bcdd/result/config/switchers/features.rb
@@ -6,15 +6,15 @@ module Features
OPTIONS = {
expectations: {
default: true,
- affects: %w[BCDD::Result::Expectations BCDD::Result::Context::Expectations]
+ affects: %w[BCDD::Result::Expectations BCDD::Context::Expectations]
},
transitions: {
default: true,
- affects: %w[BCDD::Result BCDD::Result::Context BCDD::Result::Expectations BCDD::Result::Context::Expectations]
+ affects: %w[BCDD::Result BCDD::Context BCDD::Result::Expectations BCDD::Context::Expectations]
},
and_then!: {
default: false,
- affects: %w[BCDD::Result BCDD::Result::Context BCDD::Result::Expectations BCDD::Result::Context::Expectations]
+ affects: %w[BCDD::Result BCDD::Context BCDD::Result::Expectations BCDD::Context::Expectations]
}
}.transform_values!(&:freeze).freeze
diff --git a/lib/bcdd/result/config/switchers/pattern_matching.rb b/lib/bcdd/result/config/switchers/pattern_matching.rb
index ed0ce289..1b7cb5d6 100644
--- a/lib/bcdd/result/config/switchers/pattern_matching.rb
+++ b/lib/bcdd/result/config/switchers/pattern_matching.rb
@@ -6,7 +6,7 @@ module PatternMatching
OPTIONS = {
nil_as_valid_value_checking: {
default: false,
- affects: %w[BCDD::Result::Expectations BCDD::Result::Context::Expectations]
+ affects: %w[BCDD::Result::Expectations BCDD::Context::Expectations]
}
}.transform_values!(&:freeze).freeze
diff --git a/lib/bcdd/result/context.rb b/lib/bcdd/result/context.rb
index d35dffb2..7e86eeda 100644
--- a/lib/bcdd/result/context.rb
+++ b/lib/bcdd/result/context.rb
@@ -1,93 +1,7 @@
# frozen_string_literal: true
-class BCDD::Result
- class Context < self
- require_relative 'context/failure'
- require_relative 'context/success'
- require_relative 'context/mixin'
- require_relative 'context/expectations'
- require_relative 'context/callable_and_then'
-
- EXPECTED_OUTCOME = 'BCDD::Result::Context::Success or BCDD::Result::Context::Failure'
-
- def self.Success(type, **value)
- Success.new(type: type, value: value)
- end
-
- def self.Failure(type, **value)
- Failure.new(type: type, value: value)
- end
-
- def initialize(type:, value:, source: nil, expectations: nil, terminal: nil)
- value.is_a?(::Hash) or raise ::ArgumentError, 'value must be a Hash'
-
- @acc = {}
-
- super
- end
-
- def and_then(method_name = nil, **injected_value, &block)
- super(method_name, injected_value, &block)
- end
-
- def and_then!(source, **injected_value)
- _call = injected_value.delete(:_call)
-
- acc.merge!(injected_value)
-
- super(source, injected_value, _call: _call)
- end
-
- protected
-
- attr_reader :acc
-
- private
-
- SourceMethodArity = ->(method) do
- return 0 if method.arity.zero?
+require 'bcdd/context'
- parameters = method.parameters.map(&:first)
-
- return 1 if !parameters.empty? && parameters.all?(/\Akey/)
-
- -1
- end
-
- def call_and_then_source_method!(method, injected_value)
- acc.merge!(value.merge(injected_value))
-
- case SourceMethodArity[method]
- when 0 then source.send(method.name)
- when 1 then source.send(method.name, **acc)
- else raise Error::InvalidSourceMethodArity.build(source: source, method: method, max_arity: 1)
- end
- end
-
- def call_and_then_block!(block)
- acc.merge!(value)
-
- block.call(acc)
- end
-
- def call_and_then_callable!(source, value:, injected_value:, method_name:)
- acc.merge!(value.merge(injected_value))
-
- CallableAndThen::Caller.call(source, value: acc, injected_value: injected_value, method_name: method_name)
- end
-
- def ensure_result_object(result, origin:)
- raise_unexpected_outcome_error(result, origin) unless result.is_a?(Context)
-
- return result.tap { _1.acc.merge!(acc) } if result.source.equal?(source)
-
- raise Error::InvalidResultSource.build(given_result: result, expected_source: source)
- end
-
- def raise_unexpected_outcome_error(result, origin)
- raise Error::UnexpectedOutcome.build(outcome: result, origin: origin, expected: EXPECTED_OUTCOME)
- end
-
- private_constant :SourceMethodArity
- end
+class BCDD::Result
+ Context = BCDD::Context
end
diff --git a/sig/bcdd/context.rbs b/sig/bcdd/context.rbs
new file mode 100644
index 00000000..ffacb505
--- /dev/null
+++ b/sig/bcdd/context.rbs
@@ -0,0 +1,175 @@
+class BCDD::Context < BCDD::Result
+ EXPECTED_OUTCOME: String
+
+ SourceMethodArity: ^(Method) -> Integer
+
+ attr_reader acc: Hash[Symbol, untyped]
+
+ def initialize: (
+ type: Symbol,
+ value: untyped,
+ ?source: untyped,
+ ?expectations: BCDD::Result::Contract::Evaluator,
+ ?terminal: bool
+ ) -> void
+
+ def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> untyped
+
+ def and_then!: (untyped, **untyped) -> untyped
+
+ private
+
+ def call_and_then_source_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Context
+
+ def call_and_then_callable!: (untyped, value: untyped, injected_value: untyped, method_name: (Symbol | nil)) -> BCDD::Context
+
+ def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Context
+
+ def raise_unexpected_outcome_error: (BCDD::Context | untyped, Symbol) -> void
+end
+
+class BCDD::Context
+ class Error < BCDD::Result::Error
+ class InvalidExposure < BCDD::Context::Error
+ end
+ end
+end
+
+class BCDD::Context
+ class Success < BCDD::Context
+ include BCDD::Result::Success::Methods
+
+ FetchValues: Proc
+
+ def and_expose: (Symbol, Array[Symbol], terminal: bool) -> BCDD::Context::Success
+ end
+
+ def self.Success: (Symbol, **untyped) -> BCDD::Context::Success
+end
+
+module BCDD::Context::CallableAndThen
+ class Caller < BCDD::Result::CallableAndThen::Caller
+ module KeyArgs
+ def self.parameters?: (untyped) -> bool
+
+ def self.invalid_arity: (untyped, Symbol) -> BCDD::Result::CallableAndThen::Error::InvalidArity
+ end
+
+ def self.call: (
+ untyped source,
+ value: untyped,
+ injected_value: untyped,
+ method_name: (Symbol | nil),
+ ) -> BCDD::Context
+
+ private
+
+ def self.call_proc!: (
+ untyped source,
+ Hash[Symbol, untyped] value,
+ nil injected_value
+ ) -> BCDD::Context
+
+ def self.call_method!: (
+ untyped source,
+ Method method,
+ Hash[Symbol, untyped] value,
+ nil injected_value
+ ) -> BCDD::Context
+
+ def self.callable_method: (
+ untyped source,
+ (Symbol | nil) method_name
+ ) -> ::Method
+
+ def self.ensure_result_object: (
+ untyped source,
+ untyped value,
+ BCDD::Context result
+ ) -> BCDD::Context
+
+ def self.expected_result_object: () -> singleton(BCDD::Context)
+
+ def self.expected_outcome: () -> String
+ end
+end
+
+class BCDD::Context
+ class Failure < BCDD::Context
+ include BCDD::Result::Failure::Methods
+
+ def and_expose: (Symbol, Array[Symbol], **untyped) -> BCDD::Context::Failure
+ end
+
+ def self.Failure: (Symbol, **untyped) -> BCDD::Context::Failure
+end
+
+class BCDD::Context
+ module Mixin
+ Factory: singleton(BCDD::Result::Mixin::Factory)
+
+ module Methods
+ def Success: (Symbol, **untyped) -> BCDD::Context::Success
+
+ def Failure: (Symbol, **untyped) -> BCDD::Context::Failure
+
+ private
+
+ def _ResultAs: (singleton(BCDD::Context), Symbol, untyped, ?terminal: bool) -> untyped
+ end
+
+ module Addons
+ module Continue
+ include BCDD::Context::Mixin::Methods
+
+ private
+
+ def Continue: (**untyped) -> BCDD::Context::Success
+ end
+
+ module Given
+ include BCDD::Context::Mixin::Methods
+
+ private
+
+ def Given: (*untyped) -> BCDD::Context::Success
+ end
+
+ OPTIONS: Hash[Symbol, Module]
+
+ def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
+ end
+ end
+
+ def self.mixin_module: -> singleton(BCDD::Context::Mixin)
+
+ def self.result_factory: -> singleton(BCDD::Context)
+end
+
+class BCDD::Context::Expectations < BCDD::Result::Expectations
+ def self.mixin_module: -> singleton(BCDD::Context::Expectations::Mixin)
+
+ def self.result_factory_without_expectations: -> singleton(BCDD::Result)
+
+ def Success: (Symbol, **untyped) -> BCDD::Context::Success
+ def Failure: (Symbol, **untyped) -> BCDD::Context::Failure
+end
+
+module BCDD::Context::Expectations::Mixin
+ Methods: singleton(BCDD::Result::Expectations::Mixin::Methods)
+ Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
+
+ module Addons
+ module Continue
+ private def Continue: (**untyped) -> BCDD::Context::Success
+ end
+
+ module Given
+ private def Given: (*untyped) -> BCDD::Context::Success
+ end
+
+ OPTIONS: Hash[Symbol, Module]
+
+ def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
+ end
+end
diff --git a/sig/bcdd/result/context.rbs b/sig/bcdd/result/context.rbs
index 1cbb0f29..334f4b45 100644
--- a/sig/bcdd/result/context.rbs
+++ b/sig/bcdd/result/context.rbs
@@ -1,175 +1,3 @@
-class BCDD::Result::Context < BCDD::Result
- EXPECTED_OUTCOME: String
-
- SourceMethodArity: ^(Method) -> Integer
-
- attr_reader acc: Hash[Symbol, untyped]
-
- def initialize: (
- type: Symbol,
- value: untyped,
- ?source: untyped,
- ?expectations: BCDD::Result::Contract::Evaluator,
- ?terminal: bool
- ) -> void
-
- def and_then: (?Symbol, **untyped) ?{ (Hash[Symbol, untyped]) -> untyped } -> untyped
-
- def and_then!: (untyped, **untyped) -> untyped
-
- private
-
- def call_and_then_source_method: (Symbol, Hash[Symbol, untyped]) -> BCDD::Result::Context
-
- def call_and_then_callable!: (untyped, value: untyped, injected_value: untyped, method_name: (Symbol | nil)) -> BCDD::Result::Context
-
- def ensure_result_object: (untyped, origin: Symbol) -> BCDD::Result::Context
-
- def raise_unexpected_outcome_error: (BCDD::Result::Context | untyped, Symbol) -> void
-end
-
-class BCDD::Result::Context
- class Error < BCDD::Result::Error
- class InvalidExposure < BCDD::Result::Context::Error
- end
- end
-end
-
-class BCDD::Result::Context
- class Success < BCDD::Result::Context
- include BCDD::Result::Success::Methods
-
- FetchValues: Proc
-
- def and_expose: (Symbol, Array[Symbol], terminal: bool) -> BCDD::Result::Context::Success
- end
-
- def self.Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
-end
-
-module BCDD::Result::Context::CallableAndThen
- class Caller < BCDD::Result::CallableAndThen::Caller
- module KeyArgs
- def self.parameters?: (untyped) -> bool
-
- def self.invalid_arity: (untyped, Symbol) -> BCDD::Result::CallableAndThen::Error::InvalidArity
- end
-
- def self.call: (
- untyped source,
- value: untyped,
- injected_value: untyped,
- method_name: (Symbol | nil),
- ) -> BCDD::Result::Context
-
- private
-
- def self.call_proc!: (
- untyped source,
- Hash[Symbol, untyped] value,
- nil injected_value
- ) -> BCDD::Result::Context
-
- def self.call_method!: (
- untyped source,
- Method method,
- Hash[Symbol, untyped] value,
- nil injected_value
- ) -> BCDD::Result::Context
-
- def self.callable_method: (
- untyped source,
- (Symbol | nil) method_name
- ) -> ::Method
-
- def self.ensure_result_object: (
- untyped source,
- untyped value,
- BCDD::Result::Context result
- ) -> BCDD::Result::Context
-
- def self.expected_result_object: () -> singleton(BCDD::Result::Context)
-
- def self.expected_outcome: () -> String
- end
-end
-
-class BCDD::Result::Context
- class Failure < BCDD::Result::Context
- include BCDD::Result::Failure::Methods
-
- def and_expose: (Symbol, Array[Symbol], **untyped) -> BCDD::Result::Context::Failure
- end
-
- def self.Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
-end
-
-class BCDD::Result::Context
- module Mixin
- Factory: singleton(BCDD::Result::Mixin::Factory)
-
- module Methods
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
-
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
-
- private
-
- def _ResultAs: (singleton(BCDD::Result::Context), Symbol, untyped, ?terminal: bool) -> untyped
- end
-
- module Addons
- module Continue
- include BCDD::Result::Context::Mixin::Methods
-
- private
-
- def Continue: (**untyped) -> BCDD::Result::Context::Success
- end
-
- module Given
- include BCDD::Result::Context::Mixin::Methods
-
- private
-
- def Given: (*untyped) -> BCDD::Result::Context::Success
- end
-
- OPTIONS: Hash[Symbol, Module]
-
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
- end
- end
-
- def self.mixin_module: -> singleton(BCDD::Result::Context::Mixin)
-
- def self.result_factory: -> singleton(BCDD::Result::Context)
-end
-
-class BCDD::Result::Context::Expectations < BCDD::Result::Expectations
- def self.mixin_module: -> singleton(BCDD::Result::Context::Expectations::Mixin)
-
- def self.result_factory_without_expectations: -> singleton(BCDD::Result)
-
- def Success: (Symbol, **untyped) -> BCDD::Result::Context::Success
- def Failure: (Symbol, **untyped) -> BCDD::Result::Context::Failure
-end
-
-module BCDD::Result::Context::Expectations::Mixin
- Methods: singleton(BCDD::Result::Expectations::Mixin::Methods)
- Factory: singleton(BCDD::Result::Expectations::Mixin::Factory)
-
- module Addons
- module Continue
- private def Continue: (**untyped) -> BCDD::Result::Context::Success
- end
-
- module Given
- private def Given: (*untyped) -> BCDD::Result::Context::Success
- end
-
- OPTIONS: Hash[Symbol, Module]
-
- def self.options: (Hash[Symbol, Hash[Symbol, bool]]) -> Hash[Symbol, Module]
- end
+class BCDD::Result
+ Context: BCDD::Context
end
diff --git a/test/bcdd/result/context/addons/continue/expectations_test.rb b/test/bcdd/context/addons/continue/expectations_test.rb
similarity index 91%
rename from test/bcdd/result/context/addons/continue/expectations_test.rb
rename to test/bcdd/context/addons/continue/expectations_test.rb
index 53845f6d..a668ed4d 100644
--- a/test/bcdd/result/context/addons/continue/expectations_test.rb
+++ b/test/bcdd/context/addons/continue/expectations_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsContinueExpectationsTest < Minitest::Test
+class BCDD::Context::AddonsContinueExpectationsTest < Minitest::Test
class DivideType
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :ok,
failure: :err
@@ -35,7 +35,7 @@ def divide(number1:, number2:)
end
class DivideTypes
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :division_completed,
failure: %i[invalid_arg division_by_zero]
@@ -66,7 +66,7 @@ def divide(number1:, number2:)
end
module DivideTypeAndValue
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: {
division_completed: ->(value) {
@@ -144,7 +144,7 @@ def divide(number1:, number2:)
end
class InstanceFirstSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :first
)
@@ -157,7 +157,7 @@ def call
end
class InstanceSecondSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :second
)
@@ -170,7 +170,7 @@ def call
end
class InstanceThirdSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :third
)
@@ -183,7 +183,7 @@ def call
end
module SingletonFirstSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :first
)
@@ -196,7 +196,7 @@ def call
end
module SingletonSecondSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :second
)
@@ -209,7 +209,7 @@ def call
end
module SingletonThirdSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :third
)
@@ -240,7 +240,7 @@ def call
end
class InstanceFirstSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :first
)
@@ -259,7 +259,7 @@ def third_success; Continue(third: true); end
end
class InstanceSecondSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :second
)
@@ -278,7 +278,7 @@ def third_success; Continue(third: true); end
end
class InstanceThirdSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :third
)
@@ -297,7 +297,7 @@ def third_success; Success(:third); end
end
module SingletonFirstSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :first
)
@@ -316,7 +316,7 @@ def third_success; Continue(third: true); end
end
module SingletonSecondSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :second
)
@@ -335,7 +335,7 @@ def third_success; Continue(third: true); end
end
module SingletonThirdSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :third
)
diff --git a/test/bcdd/result/context/addons/continue/instance_test.rb b/test/bcdd/context/addons/continue/instance_test.rb
similarity index 86%
rename from test/bcdd/result/context/addons/continue/instance_test.rb
rename to test/bcdd/context/addons/continue/instance_test.rb
index 4ab905f9..bc3068a5 100644
--- a/test/bcdd/result/context/addons/continue/instance_test.rb
+++ b/test/bcdd/context/addons/continue/instance_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsContinueInstanceTest < Minitest::Test
+class BCDD::Context::AddonsContinueInstanceTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call(arg1, arg2)
validate_numbers(arg1, arg2)
@@ -57,7 +57,7 @@ def divide(number1:, number2:)
end
class FirstSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Success(:first)
@@ -67,7 +67,7 @@ def call
end
class SecondSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Continue(first: true)
@@ -77,7 +77,7 @@ def call
end
class ThirdSuccessToTerminateTheStepChainAndThenBlock
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Continue(first: true)
@@ -97,7 +97,7 @@ def call
end
class FirstSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
@@ -113,7 +113,7 @@ def third_success; Continue(third: true); end
end
class SecondSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
@@ -129,7 +129,7 @@ def third_success; Continue(third: true); end
end
class ThirdSuccessToTerminateTheStepChainAndThenMethod
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
diff --git a/test/bcdd/result/context/addons/continue/singleton_test.rb b/test/bcdd/context/addons/continue/singleton_test.rb
similarity index 86%
rename from test/bcdd/result/context/addons/continue/singleton_test.rb
rename to test/bcdd/context/addons/continue/singleton_test.rb
index ac17bb16..691fca7b 100644
--- a/test/bcdd/result/context/addons/continue/singleton_test.rb
+++ b/test/bcdd/context/addons/continue/singleton_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsContinueSingletonTest < Minitest::Test
+class BCDD::Context::AddonsContinueSingletonTest < Minitest::Test
module Divide
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call(arg1, arg2)
validate_numbers(arg1, arg2)
@@ -57,7 +57,7 @@ def divide(number1:, number2:, extra_division:)
end
module FirstSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Success(:first)
@@ -67,7 +67,7 @@ def call
end
module SecondSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Continue(first: true)
@@ -77,7 +77,7 @@ def call
end
module ThirdSuccessToTerminateTheStepChainAndThenBlock
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
Continue(first: true)
@@ -97,7 +97,7 @@ def call
end
module FirstSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
@@ -113,7 +113,7 @@ def third_success; Continue(third: true); end
end
module SecondSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
@@ -129,7 +129,7 @@ def third_success; Continue(third: true); end
end
module ThirdSuccessToTerminateTheStepChainAndThenMethod
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call
first_success
diff --git a/test/bcdd/result/context/addons/given/expectations_test.rb b/test/bcdd/context/addons/given/expectations_test.rb
similarity index 92%
rename from test/bcdd/result/context/addons/given/expectations_test.rb
rename to test/bcdd/context/addons/given/expectations_test.rb
index 6a025aa8..00e07db3 100644
--- a/test/bcdd/result/context/addons/given/expectations_test.rb
+++ b/test/bcdd/context/addons/given/expectations_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsGivenExpectationsTest < Minitest::Test
+class BCDD::Context::AddonsGivenExpectationsTest < Minitest::Test
class DivideType
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :ok,
failure: :err
@@ -36,7 +36,7 @@ def divide(number1:, number2:)
end
class DivideTypes
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: :division_completed,
failure: %i[invalid_arg division_by_zero]
@@ -68,7 +68,7 @@ def divide(number1:, number2:)
end
module DivideTypeAndValue
- extend self, BCDD::Result::Context::Expectations.mixin(
+ extend self, BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: {
division_completed: ->(value) {
diff --git a/test/bcdd/result/context/addons/given/instance_test.rb b/test/bcdd/context/addons/given/instance_test.rb
similarity index 91%
rename from test/bcdd/result/context/addons/given/instance_test.rb
rename to test/bcdd/context/addons/given/instance_test.rb
index dba2a133..08afda19 100644
--- a/test/bcdd/result/context/addons/given/instance_test.rb
+++ b/test/bcdd/context/addons/given/instance_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsGivenInstanceTest < Minitest::Test
+class BCDD::Context::AddonsGivenInstanceTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ include BCDD::Context.mixin(config: { addon: { continue: true } })
def call(arg1, arg2)
Given(number1: arg1, number2: arg2)
diff --git a/test/bcdd/result/context/addons/given/singleton_test.rb b/test/bcdd/context/addons/given/singleton_test.rb
similarity index 91%
rename from test/bcdd/result/context/addons/given/singleton_test.rb
rename to test/bcdd/context/addons/given/singleton_test.rb
index e6a67125..224fdc7a 100644
--- a/test/bcdd/result/context/addons/given/singleton_test.rb
+++ b/test/bcdd/context/addons/given/singleton_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::AddonsGivenSingletonTest < Minitest::Test
+class BCDD::Context::AddonsGivenSingletonTest < Minitest::Test
module Divide
- extend self, BCDD::Result::Context.mixin(config: { addon: { continue: true } })
+ extend self, BCDD::Context.mixin(config: { addon: { continue: true } })
def call(arg1, arg2)
Given(number1: arg1, number2: arg2)
diff --git a/test/bcdd/result/context/and_expose/all_values_test.rb b/test/bcdd/context/and_expose/all_values_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_expose/all_values_test.rb
rename to test/bcdd/context/and_expose/all_values_test.rb
index e0e33ed6..28314327 100644
--- a/test/bcdd/result/context/and_expose/all_values_test.rb
+++ b/test/bcdd/context/and_expose/all_values_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeAllValuesTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
diff --git a/test/bcdd/result/context/and_expose/argument_error_test.rb b/test/bcdd/context/and_expose/argument_error_test.rb
similarity index 89%
rename from test/bcdd/result/context/and_expose/argument_error_test.rb
rename to test/bcdd/context/and_expose/argument_error_test.rb
index 808a7663..d3a00f23 100644
--- a/test/bcdd/result/context/and_expose/argument_error_test.rb
+++ b/test/bcdd/context/and_expose/argument_error_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeArgumentErrorTest < Minitest::Test
class NotAnArray
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Success(:ok, number: 1)
@@ -14,7 +14,7 @@ def call
end
class EmptyArray
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Success(:ok, number: 1)
@@ -23,7 +23,7 @@ def call
end
class AnyKeyAreNotSymbol
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Success(:ok, number: 1)
diff --git a/test/bcdd/result/context/and_expose/expectations_test.rb b/test/bcdd/context/and_expose/expectations_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_expose/expectations_test.rb
rename to test/bcdd/context/and_expose/expectations_test.rb
index 619147e3..4cbb07b1 100644
--- a/test/bcdd/result/context/and_expose/expectations_test.rb
+++ b/test/bcdd/context/and_expose/expectations_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextExpectationsTest < Minitest::Test
class Divide1
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: { division_completed: ->(value) { value[:final_number].is_a?(Numeric) } },
failure: { invalid_arg: ->(value) { value[:message].is_a?(String) } }
@@ -32,7 +32,7 @@ def divide(number1:, number2:)
end
class Divide2
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { addon: { continue: true } },
success: { division_completed: ->(value) { value[:final_number].is_a?(Numeric) } },
failure: { invalid_arg: ->(value) { value[:message].is_a?(String) } }
diff --git a/test/bcdd/result/context/and_expose/failure_test.rb b/test/bcdd/context/and_expose/failure_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_expose/failure_test.rb
rename to test/bcdd/context/and_expose/failure_test.rb
index 832eeed5..a6006ceb 100644
--- a/test/bcdd/result/context/and_expose/failure_test.rb
+++ b/test/bcdd/context/and_expose/failure_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeFailureTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
diff --git a/test/bcdd/result/context/and_expose/intermediate_values_test.rb b/test/bcdd/context/and_expose/intermediate_values_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_expose/intermediate_values_test.rb
rename to test/bcdd/context/and_expose/intermediate_values_test.rb
index 2667c60c..e6c6d868 100644
--- a/test/bcdd/result/context/and_expose/intermediate_values_test.rb
+++ b/test/bcdd/context/and_expose/intermediate_values_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeIntermediateValuesTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
diff --git a/test/bcdd/result/context/and_expose/invalid_keys_test.rb b/test/bcdd/context/and_expose/invalid_keys_test.rb
similarity index 86%
rename from test/bcdd/result/context/and_expose/invalid_keys_test.rb
rename to test/bcdd/context/and_expose/invalid_keys_test.rb
index 49bd35c3..21f2231c 100644
--- a/test/bcdd/result/context/and_expose/invalid_keys_test.rb
+++ b/test/bcdd/context/and_expose/invalid_keys_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeInvalidKeysTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
@@ -28,7 +28,7 @@ def divide(number1:, number2:, extra_division:)
end
test '#and_expose receive an invalid key' do
- err = assert_raises(BCDD::Result::Context::Error::InvalidExposure) { Divide.new.call(12, 2) }
+ err = assert_raises(BCDD::Context::Error::InvalidExposure) { Divide.new.call(12, 2) }
assert err.message.start_with?('key not found: :final_numbers')
assert err.message.end_with?('. Available to expose: :number1, :number2, :extra_division, :final_number')
diff --git a/test/bcdd/result/context/and_expose/one_value_test.rb b/test/bcdd/context/and_expose/one_value_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_expose/one_value_test.rb
rename to test/bcdd/context/and_expose/one_value_test.rb
index cc54ffbf..00f62f1a 100644
--- a/test/bcdd/result/context/and_expose/one_value_test.rb
+++ b/test/bcdd/context/and_expose/one_value_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndExposeOneValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(arg1, arg2)
validate_numbers(arg1, arg2)
diff --git a/test/bcdd/result/context/and_expose/termination_test.rb b/test/bcdd/context/and_expose/termination_test.rb
similarity index 99%
rename from test/bcdd/result/context/and_expose/termination_test.rb
rename to test/bcdd/context/and_expose/termination_test.rb
index 1d8aab94..64078d1a 100644
--- a/test/bcdd/result/context/and_expose/termination_test.rb
+++ b/test/bcdd/context/and_expose/termination_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextTerminationTest < Minitest::Test
module TerminationEnabledAndThenBlock
extend self, Context.mixin
diff --git a/test/bcdd/result/context/and_then/argument_error_test.rb b/test/bcdd/context/and_then/argument_error_test.rb
similarity index 90%
rename from test/bcdd/result/context/and_then/argument_error_test.rb
rename to test/bcdd/context/and_then/argument_error_test.rb
index acb4eb42..29173a9e 100644
--- a/test/bcdd/result/context/and_then/argument_error_test.rb
+++ b/test/bcdd/context/and_then/argument_error_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndThenArgumentErrorTest < Minitest::Test
module SomeModule
- extend BCDD::Result::Context.mixin
+ extend BCDD::Context.mixin
def self.call(arg1, arg2)
Success(:ok, number: arg1 + arg2)
diff --git a/test/bcdd/result/context/and_then/with_source_test.rb b/test/bcdd/context/and_then/with_source_test.rb
similarity index 94%
rename from test/bcdd/result/context/and_then/with_source_test.rb
rename to test/bcdd/context/and_then/with_source_test.rb
index f00152dc..bc2ad1a1 100644
--- a/test/bcdd/result/context/and_then/with_source_test.rb
+++ b/test/bcdd/context/and_then/with_source_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndThenWithSourceTest < Minitest::Test
class Base
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
attr_reader :arg1, :arg2
@@ -172,7 +172,7 @@ def add
"You cannot call #and_then and return a result that does not belong to the same source!\n" \
"Expected source: #{wrong_result_source.inspect}\n" \
"Given source: #{wrong_result_source.add_instance.inspect}\n" \
- 'Given result: #3}>'
+ 'Given result: #3}>'
assert_equal(expected_message, error.message)
end
@@ -186,7 +186,7 @@ def add
"You cannot call #and_then and return a result that does not belong to the same source!\n" \
"Expected source: #{wrong_result_source.inspect}\n" \
"Given source: #{wrong_result_source.add_instance.inspect}\n" \
- 'Given result: #3}>'
+ 'Given result: #3}>'
assert_equal(expected_message, error.message)
end
@@ -196,7 +196,7 @@ def add
expected_message =
'Unexpected outcome: 3. The block must return this object wrapped by ' \
- 'BCDD::Result::Context::Success or BCDD::Result::Context::Failure'
+ 'BCDD::Context::Success or BCDD::Context::Failure'
assert_equal(expected_message, error.message)
end
@@ -206,7 +206,7 @@ def add
expected_message =
'Unexpected outcome: 3. The method must return this object wrapped by ' \
- 'BCDD::Result::Context::Success or BCDD::Result::Context::Failure'
+ 'BCDD::Context::Success or BCDD::Context::Failure'
assert_equal(expected_message, error.message)
end
diff --git a/test/bcdd/result/context/and_then/without_source_test.rb b/test/bcdd/context/and_then/without_source_test.rb
similarity index 84%
rename from test/bcdd/result/context/and_then/without_source_test.rb
rename to test/bcdd/context/and_then/without_source_test.rb
index af8b8ad8..e0bfa936 100644
--- a/test/bcdd/result/context/and_then/without_source_test.rb
+++ b/test/bcdd/context/and_then/without_source_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextAndThenWithoutSourceTest < Minitest::Test
test '#and_then does not execute the block if the result is a failure' do
result =
@@ -38,7 +38,7 @@ class ContextAndThenWithoutSourceTest < Minitest::Test
end
test '#and_then raises an exception if the block does not return a result context (regular object)' do
- error = assert_raises(BCDD::Result::Context::Error::UnexpectedOutcome) do
+ error = assert_raises(BCDD::Context::Error::UnexpectedOutcome) do
Context::Success(:one, number: 1)
.and_then { Context::Success(:two, number: 2) }
.and_then { 3 }
@@ -46,13 +46,13 @@ class ContextAndThenWithoutSourceTest < Minitest::Test
assert_equal(
'Unexpected outcome: 3. The block must return this object wrapped by ' \
- 'BCDD::Result::Context::Success or BCDD::Result::Context::Failure',
+ 'BCDD::Context::Success or BCDD::Context::Failure',
error.message
)
end
test '#and_then raises an exception if the block does not return a result context (BCDD::Result)' do
- error = assert_raises(BCDD::Result::Context::Error::UnexpectedOutcome) do
+ error = assert_raises(BCDD::Context::Error::UnexpectedOutcome) do
Context::Success(:one, number: 1)
.and_then { Context::Success(:two, number: 2) }
.and_then { BCDD::Result::Success(:three, number: 3) }
@@ -60,7 +60,7 @@ class ContextAndThenWithoutSourceTest < Minitest::Test
assert_equal(
'Unexpected outcome: #3}>. ' \
- 'The block must return this object wrapped by BCDD::Result::Context::Success or BCDD::Result::Context::Failure',
+ 'The block must return this object wrapped by BCDD::Context::Success or BCDD::Context::Failure',
error.message
)
end
diff --git a/test/bcdd/result/context/callable_and_then/accumulation_test.rb b/test/bcdd/context/callable_and_then/accumulation_test.rb
similarity index 99%
rename from test/bcdd/result/context/callable_and_then/accumulation_test.rb
rename to test/bcdd/context/callable_and_then/accumulation_test.rb
index 0318b222..7cc84f21 100644
--- a/test/bcdd/result/context/callable_and_then/accumulation_test.rb
+++ b/test/bcdd/context/callable_and_then/accumulation_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::CallableAndThenResultFromDifferentSourcesTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/callable_and_then/arity_test.rb b/test/bcdd/context/callable_and_then/arity_test.rb
similarity index 99%
rename from test/bcdd/result/context/callable_and_then/arity_test.rb
rename to test/bcdd/context/callable_and_then/arity_test.rb
index 8f1e1650..286c8997 100644
--- a/test/bcdd/result/context/callable_and_then/arity_test.rb
+++ b/test/bcdd/context/callable_and_then/arity_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::CallableAndThenArityTest < Minitest::Test
# rubocop:disable Naming/MethodParameterName
ProcWithoutKarg = proc { Context::Success(:ok, o: -1) }
diff --git a/test/bcdd/result/context/callable_and_then/result_kind_error_test.rb b/test/bcdd/context/callable_and_then/result_kind_error_test.rb
similarity index 90%
rename from test/bcdd/result/context/callable_and_then/result_kind_error_test.rb
rename to test/bcdd/context/callable_and_then/result_kind_error_test.rb
index da989206..8b76daae 100644
--- a/test/bcdd/result/context/callable_and_then/result_kind_error_test.rb
+++ b/test/bcdd/context/callable_and_then/result_kind_error_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::CallableAndThenResultKindErrorTest < Minitest::Test
module NormalizeEmail
extend Context.mixin
@@ -38,7 +38,7 @@ def self.call(input)
expected_message = [
'Unexpected outcome: #"input must be a String"}>.',
- 'The method must return this object wrapped by BCDD::Result::Context::Success or BCDD::Result::Context::Failure'
+ 'The method must return this object wrapped by BCDD::Context::Success or BCDD::Context::Failure'
].join(' ')
assert_equal(expected_message, error.message)
diff --git a/test/bcdd/result/context/callable_and_then/results_from_different_sources_test.rb b/test/bcdd/context/callable_and_then/results_from_different_sources_test.rb
similarity index 99%
rename from test/bcdd/result/context/callable_and_then/results_from_different_sources_test.rb
rename to test/bcdd/context/callable_and_then/results_from_different_sources_test.rb
index a4a84920..541574b1 100644
--- a/test/bcdd/result/context/callable_and_then/results_from_different_sources_test.rb
+++ b/test/bcdd/context/callable_and_then/results_from_different_sources_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::CallableAndThenResultFromDifferentSourcesTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/callable_and_then/unexpected_outcome_test.rb b/test/bcdd/context/callable_and_then/unexpected_outcome_test.rb
similarity index 90%
rename from test/bcdd/result/context/callable_and_then/unexpected_outcome_test.rb
rename to test/bcdd/context/callable_and_then/unexpected_outcome_test.rb
index 9a98a284..cdaaf398 100644
--- a/test/bcdd/result/context/callable_and_then/unexpected_outcome_test.rb
+++ b/test/bcdd/context/callable_and_then/unexpected_outcome_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::CallableAndThenUnexpectedOutcomeTest < Minitest::Test
ProcWithArg = proc { |arg:| arg }
@@ -27,7 +27,7 @@ def teardown
Context::Success(:ok, arg: 0).and_then!(ModWithArg)
end
- expected_kinds = 'BCDD::Result::Context::Success or BCDD::Result::Context::Failure'
+ expected_kinds = 'BCDD::Context::Success or BCDD::Context::Failure'
assert_match(
/Unexpected outcome: 0. The # must return this object wrapped by #{expected_kinds}/,
diff --git a/test/bcdd/result/context/expectations/mixin_constants_test.rb b/test/bcdd/context/expectations/mixin_constants_test.rb
similarity index 56%
rename from test/bcdd/result/context/expectations/mixin_constants_test.rb
rename to test/bcdd/context/expectations/mixin_constants_test.rb
index 1fe5a97e..a66055ee 100644
--- a/test/bcdd/result/context/expectations/mixin_constants_test.rb
+++ b/test/bcdd/context/expectations/mixin_constants_test.rb
@@ -2,24 +2,24 @@
require 'test_helper'
-class BCDD::Result::Context::Expectations::MixinConstantsTest < Minitest::Test
+class BCDD::Context::Expectations::MixinConstantsTest < Minitest::Test
class IncludingInClass
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
end
module IncludingInModule
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
end
class ExtendingInClass
- extend BCDD::Result::Context::Expectations.mixin
+ extend BCDD::Context::Expectations.mixin
end
module ExtendingInModule
- extend BCDD::Result::Context::Expectations.mixin
+ extend BCDD::Context::Expectations.mixin
end
- test 'BCDD::Result::Context::Expectations.mixin sets a constant in all classes/modules' do
+ test 'BCDD::Context::Expectations.mixin sets a constant in all classes/modules' do
assert IncludingInClass.const_defined?(:ResultExpectationsMixin, false)
assert IncludingInModule.const_defined?(:ResultExpectationsMixin, false)
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/failure/type/invalid_type_test.rb
similarity index 87%
rename from test/bcdd/result/context/expectations/with_source/failure/type/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type/invalid_type_test.rb
index ca55539a..45c7e92e 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureInvalidTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb
similarity index 88%
rename from test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb
index 3e558a4f..ccc687a5 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureInvalidTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureInvalidTypeAndValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: {
err1: ->(value) { value.is_a?(Hash) && value[:message].is_a?(String) },
err2: ->(value) { value.is_a?(Hash) && value[:message].is_a?(String) }
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb b/test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb
similarity index 85%
rename from test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb
index 1cd476b6..37312bd0 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type_and_value/invalid_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureTypeAndValueInvalidValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureTypeAndValueInvalidValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: {
invalid_arg: ->(value) { value.is_a?(Hash) && value[:message].is_a?(String) },
division_by_zero: ->(value) { value.is_a?(Hash) && value[:message].is_a?(String) }
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb b/test/bcdd/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb
similarity index 86%
rename from test/bcdd/result/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb
index 81b1d1cf..fcd0901b 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type_and_value/pattern_matching_error_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureTypeAndValuePatterMatchingErrorTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureTypeAndValuePatterMatchingErrorTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: {
invalid_arg: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type_and_value_test.rb b/test/bcdd/context/expectations/with_source/failure/type_and_value_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/with_source/failure/type_and_value_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type_and_value_test.rb
index ba5b03bb..e3aacd26 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureTypeAndValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: {
invalid_arg: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/failure/type_test.rb b/test/bcdd/context/expectations/with_source/failure/type_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/with_source/failure/type_test.rb
rename to test/bcdd/context/expectations/with_source/failure/type_test.rb
index f5d1f163..d86bf121 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/type_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/with_source/failure/types/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/failure/types/invalid_type_test.rb
similarity index 87%
rename from test/bcdd/result/context/expectations/with_source/failure/types/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/failure/types/invalid_type_test.rb
index 71a439bc..4904af0c 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/types/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/types/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureInvalidTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureInvalidTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: %i[err1 err2]
)
diff --git a/test/bcdd/result/context/expectations/with_source/failure/types_test.rb b/test/bcdd/context/expectations/with_source/failure/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/failure/types_test.rb
rename to test/bcdd/context/expectations/with_source/failure/types_test.rb
index 0d6697dd..85a5e2f5 100644
--- a/test/bcdd/result/context/expectations/with_source/failure/types_test.rb
+++ b/test/bcdd/context/expectations/with_source/failure/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceFailureTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceFailureTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
failure: %i[invalid_arg division_by_zero]
)
diff --git a/test/bcdd/result/context/expectations/with_source/success/type/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/success/type/invalid_type_test.rb
similarity index 83%
rename from test/bcdd/result/context/expectations/with_source/success/type/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/success/type/invalid_type_test.rb
index 2039bad6..b50e6792 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessInvalidTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: :ok
)
diff --git a/test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/success/type_and_value/invalid_type_test.rb
similarity index 84%
rename from test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/success/type_and_value/invalid_type_test.rb
index 39a6d627..b654070e 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type_and_value/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypeAndValueInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypeAndValueInvalidTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
division_completed: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_value_test.rb b/test/bcdd/context/expectations/with_source/success/type_and_value/invalid_value_test.rb
similarity index 84%
rename from test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_value_test.rb
rename to test/bcdd/context/expectations/with_source/success/type_and_value/invalid_value_test.rb
index 89750c9d..a8d68a51 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type_and_value/invalid_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type_and_value/invalid_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypeAndValueInvalidValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypeAndValueInvalidValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
division_completed: ->(value) {
value.is_a?(::Hash) && value[:number].is_a?(::Numeric)
diff --git a/test/bcdd/result/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb b/test/bcdd/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb
similarity index 84%
rename from test/bcdd/result/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb
rename to test/bcdd/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb
index f561e281..b7eab9a0 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type_and_value/pattern_matching_error_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypeAndValuePatterMatchingErrorTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypeAndValuePatterMatchingErrorTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
division_completed: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/success/type_and_value_test.rb b/test/bcdd/context/expectations/with_source/success/type_and_value_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/with_source/success/type_and_value_test.rb
rename to test/bcdd/context/expectations/with_source/success/type_and_value_test.rb
index 7e76c53f..befa5936 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypeAndValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/success/type_test.rb b/test/bcdd/context/expectations/with_source/success/type_test.rb
similarity index 95%
rename from test/bcdd/result/context/expectations/with_source/success/type_test.rb
rename to test/bcdd/context/expectations/with_source/success/type_test.rb
index 4bcd8107..e55d9c1f 100644
--- a/test/bcdd/result/context/expectations/with_source/success/type_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: :ok
)
diff --git a/test/bcdd/result/context/expectations/with_source/success/types/invalid_type_test.rb b/test/bcdd/context/expectations/with_source/success/types/invalid_type_test.rb
similarity index 87%
rename from test/bcdd/result/context/expectations/with_source/success/types/invalid_type_test.rb
rename to test/bcdd/context/expectations/with_source/success/types/invalid_type_test.rb
index 72498884..e71aa749 100644
--- a/test/bcdd/result/context/expectations/with_source/success/types/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/types/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessInvalidTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessInvalidTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: %i[ok1 ok2 ok3]
)
diff --git a/test/bcdd/result/context/expectations/with_source/success/types_test.rb b/test/bcdd/context/expectations/with_source/success/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/success/types_test.rb
rename to test/bcdd/context/expectations/with_source/success/types_test.rb
index 8598e762..485e3020 100644
--- a/test/bcdd/result/context/expectations/with_source/success/types_test.rb
+++ b/test/bcdd/context/expectations/with_source/success/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: %i[numbers division_completed]
)
diff --git a/test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb b/test/bcdd/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb
rename to test/bcdd/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb
index 8697a974..2f164318 100644
--- a/test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb
+++ b/test/bcdd/context/expectations/with_source/success_and_failure/mixed/type_and_value_with_types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessAndFailureTypeAndValueWithTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessAndFailureTypeAndValueWithTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb b/test/bcdd/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb
rename to test/bcdd/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb
index fdae006f..ef9c00e8 100644
--- a/test/bcdd/result/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/success_and_failure/mixed/types_with_type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessAndFailureTypesWithTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessAndFailureTypesWithTypeAndValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: %i[numbers division_completed],
failure: {
invalid_arg: ->(value) {
diff --git a/test/bcdd/result/context/expectations/with_source/success_and_failure/type_and_value_test.rb b/test/bcdd/context/expectations/with_source/success_and_failure/type_and_value_test.rb
similarity index 98%
rename from test/bcdd/result/context/expectations/with_source/success_and_failure/type_and_value_test.rb
rename to test/bcdd/context/expectations/with_source/success_and_failure/type_and_value_test.rb
index 06391d88..2f0a22bc 100644
--- a/test/bcdd/result/context/expectations/with_source/success_and_failure/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/with_source/success_and_failure/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessAndFailureTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessAndFailureTypeAndValueTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/with_source/success_and_failure/type_test.rb b/test/bcdd/context/expectations/with_source/success_and_failure/type_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/success_and_failure/type_test.rb
rename to test/bcdd/context/expectations/with_source/success_and_failure/type_test.rb
index 54506612..b74056dc 100644
--- a/test/bcdd/result/context/expectations/with_source/success_and_failure/type_test.rb
+++ b/test/bcdd/context/expectations/with_source/success_and_failure/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessAndFailureTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessAndFailureTypeTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: :ok,
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/with_source/success_and_failure/types_test.rb b/test/bcdd/context/expectations/with_source/success_and_failure/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/with_source/success_and_failure/types_test.rb
rename to test/bcdd/context/expectations/with_source/success_and_failure/types_test.rb
index a35f63a9..a488bd33 100644
--- a/test/bcdd/result/context/expectations/with_source/success_and_failure/types_test.rb
+++ b/test/bcdd/context/expectations/with_source/success_and_failure/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithSourceSuccessAndFailureTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithSourceSuccessAndFailureTypesTest < Minitest::Test
class Divide
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
success: %i[numbers division_completed],
failure: %i[invalid_arg division_by_zero]
)
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/failure/type/invalid_type_test.rb
similarity index 88%
rename from test/bcdd/result/context/expectations/without_source/failure/type/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type/invalid_type_test.rb
index 883e76b0..8b3479e4 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureInvalidTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb
similarity index 93%
rename from test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb
index 111b17c7..89c205e6 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_type_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureInvalidTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureInvalidTypeAndValueTest < Minitest::Test
class Divide
Result = BCDD::Result::Expectations.new(
failure: {
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb b/test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb
similarity index 87%
rename from test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb
index 58807fcb..b5322160 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type_and_value/invalid_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureTypeAndValueInvalidValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureTypeAndValueInvalidValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: {
invalid_arg: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb b/test/bcdd/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb
similarity index 87%
rename from test/bcdd/result/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb
index fb39bc7e..76b281ac 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type_and_value/pattern_matching_error_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureTypeAndValuePatterMatchingErrorTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureTypeAndValuePatterMatchingErrorTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: {
invalid_arg: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type_and_value_test.rb b/test/bcdd/context/expectations/without_source/failure/type_and_value_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/without_source/failure/type_and_value_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type_and_value_test.rb
index b69c8bc9..e03efdd9 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureTypeAndValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: {
invalid_arg: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/failure/type_test.rb b/test/bcdd/context/expectations/without_source/failure/type_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/without_source/failure/type_test.rb
rename to test/bcdd/context/expectations/without_source/failure/type_test.rb
index dcc1e668..8ab20bcd 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/type_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/without_source/failure/types/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/failure/types/invalid_type_test.rb
similarity index 88%
rename from test/bcdd/result/context/expectations/without_source/failure/types/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/failure/types/invalid_type_test.rb
index 3174ecfa..0d230c4d 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/types/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/types/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureInvalidTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureInvalidTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: %i[err1 err2]
)
diff --git a/test/bcdd/result/context/expectations/without_source/failure/types_test.rb b/test/bcdd/context/expectations/without_source/failure/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/failure/types_test.rb
rename to test/bcdd/context/expectations/without_source/failure/types_test.rb
index cc5b8a44..4b8e573e 100644
--- a/test/bcdd/result/context/expectations/without_source/failure/types_test.rb
+++ b/test/bcdd/context/expectations/without_source/failure/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceFailureTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceFailureTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
failure: %i[invalid_arg division_by_zero]
)
diff --git a/test/bcdd/result/context/expectations/without_source/success/type/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/success/type/invalid_type_test.rb
similarity index 83%
rename from test/bcdd/result/context/expectations/without_source/success/type/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/success/type/invalid_type_test.rb
index 0fafc741..d73ed1ed 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessInvalidTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: :ok
)
diff --git a/test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/success/type_and_value/invalid_type_test.rb
similarity index 84%
rename from test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/success/type_and_value/invalid_type_test.rb
index bc5ac1f8..6fe184e7 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type_and_value/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypeAndValueInvalidTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypeAndValueInvalidTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
division_completed: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_value_test.rb b/test/bcdd/context/expectations/without_source/success/type_and_value/invalid_value_test.rb
similarity index 85%
rename from test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_value_test.rb
rename to test/bcdd/context/expectations/without_source/success/type_and_value/invalid_value_test.rb
index 1e45b319..d425a943 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type_and_value/invalid_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type_and_value/invalid_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypeAndValueInvalidValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypeAndValueInvalidValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
division_completed: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb b/test/bcdd/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb
similarity index 85%
rename from test/bcdd/result/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb
rename to test/bcdd/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb
index ad3f447a..85d33aa7 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type_and_value/pattern_matching_error_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypeAndValuePatterMatchingErrorTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypeAndValuePatterMatchingErrorTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
division_completed: ->(value) do
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success/type_and_value_test.rb b/test/bcdd/context/expectations/without_source/success/type_and_value_test.rb
similarity index 96%
rename from test/bcdd/result/context/expectations/without_source/success/type_and_value_test.rb
rename to test/bcdd/context/expectations/without_source/success/type_and_value_test.rb
index 851dd6a7..5c5fa088 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypeAndValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success/type_test.rb b/test/bcdd/context/expectations/without_source/success/type_test.rb
similarity index 95%
rename from test/bcdd/result/context/expectations/without_source/success/type_test.rb
rename to test/bcdd/context/expectations/without_source/success/type_test.rb
index 64f3f7b4..33fd1870 100644
--- a/test/bcdd/result/context/expectations/without_source/success/type_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: :ok
)
diff --git a/test/bcdd/result/context/expectations/without_source/success/types/invalid_type_test.rb b/test/bcdd/context/expectations/without_source/success/types/invalid_type_test.rb
similarity index 88%
rename from test/bcdd/result/context/expectations/without_source/success/types/invalid_type_test.rb
rename to test/bcdd/context/expectations/without_source/success/types/invalid_type_test.rb
index 7a7bd188..954c3ff0 100644
--- a/test/bcdd/result/context/expectations/without_source/success/types/invalid_type_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/types/invalid_type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessInvalidTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessInvalidTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: %i[ok1 ok2 ok3]
)
diff --git a/test/bcdd/result/context/expectations/without_source/success/types_test.rb b/test/bcdd/context/expectations/without_source/success/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/success/types_test.rb
rename to test/bcdd/context/expectations/without_source/success/types_test.rb
index 2cfc064e..e48d597e 100644
--- a/test/bcdd/result/context/expectations/without_source/success/types_test.rb
+++ b/test/bcdd/context/expectations/without_source/success/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: %i[numbers division_completed]
)
diff --git a/test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb b/test/bcdd/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb
rename to test/bcdd/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb
index 291c4fee..63d750fb 100644
--- a/test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb
+++ b/test/bcdd/context/expectations/without_source/success_and_failure/mixed/type_and_value_with_types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessAndFailureTypeAndValueWithTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessAndFailureTypeAndValueWithTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb b/test/bcdd/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb
rename to test/bcdd/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb
index b08fdfdb..b8a3b1e7 100644
--- a/test/bcdd/result/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/success_and_failure/mixed/types_with_type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessAndFailureTypesWithTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessAndFailureTypesWithTypeAndValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: %i[numbers division_completed],
failure: {
invalid_arg: ->(value) {
diff --git a/test/bcdd/result/context/expectations/without_source/success_and_failure/type_and_value_test.rb b/test/bcdd/context/expectations/without_source/success_and_failure/type_and_value_test.rb
similarity index 98%
rename from test/bcdd/result/context/expectations/without_source/success_and_failure/type_and_value_test.rb
rename to test/bcdd/context/expectations/without_source/success_and_failure/type_and_value_test.rb
index c319d462..8a039355 100644
--- a/test/bcdd/result/context/expectations/without_source/success_and_failure/type_and_value_test.rb
+++ b/test/bcdd/context/expectations/without_source/success_and_failure/type_and_value_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessAndFailureTypeAndValueTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessAndFailureTypeAndValueTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: {
numbers: ->(value) {
case value
diff --git a/test/bcdd/result/context/expectations/without_source/success_and_failure/type_test.rb b/test/bcdd/context/expectations/without_source/success_and_failure/type_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/success_and_failure/type_test.rb
rename to test/bcdd/context/expectations/without_source/success_and_failure/type_test.rb
index 2f001917..df759daf 100644
--- a/test/bcdd/result/context/expectations/without_source/success_and_failure/type_test.rb
+++ b/test/bcdd/context/expectations/without_source/success_and_failure/type_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessAndFailureTypeTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessAndFailureTypeTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: :ok,
failure: :err
)
diff --git a/test/bcdd/result/context/expectations/without_source/success_and_failure/types_test.rb b/test/bcdd/context/expectations/without_source/success_and_failure/types_test.rb
similarity index 97%
rename from test/bcdd/result/context/expectations/without_source/success_and_failure/types_test.rb
rename to test/bcdd/context/expectations/without_source/success_and_failure/types_test.rb
index 2343ecae..60c2ce71 100644
--- a/test/bcdd/result/context/expectations/without_source/success_and_failure/types_test.rb
+++ b/test/bcdd/context/expectations/without_source/success_and_failure/types_test.rb
@@ -2,9 +2,9 @@
require 'test_helper'
-class BCDD::Result::Context::ExpectationsWithoutSourceSuccessAndFailureTypesTest < Minitest::Test
+class BCDD::Context::ExpectationsWithoutSourceSuccessAndFailureTypesTest < Minitest::Test
class Divide
- Result = BCDD::Result::Context::Expectations.new(
+ Result = BCDD::Context::Expectations.new(
success: %i[numbers division_completed],
failure: %i[invalid_arg division_by_zero]
)
diff --git a/test/bcdd/result/context/failure_test.rb b/test/bcdd/context/failure_test.rb
similarity index 66%
rename from test/bcdd/result/context/failure_test.rb
rename to test/bcdd/context/failure_test.rb
index cbcdba7f..ec6e27ca 100644
--- a/test/bcdd/result/context/failure_test.rb
+++ b/test/bcdd/context/failure_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextFailureTest < Minitest::Test
- test 'is a BCDD::Result::Context' do
- assert Context::Failure < BCDD::Result::Context
+ test 'is a BCDD::Context' do
+ assert Context::Failure < BCDD::Context
end
test 'has BCDD::Result::Failure::Methods' do
@@ -16,7 +16,7 @@ class ContextFailureTest < Minitest::Test
result = Context::Failure(:err, number: 0)
assert_equal(
- '#0}>',
+ '#0}>',
result.inspect
)
end
diff --git a/test/bcdd/result/context/mixin_constants_test.rb b/test/bcdd/context/mixin_constants_test.rb
similarity index 60%
rename from test/bcdd/result/context/mixin_constants_test.rb
rename to test/bcdd/context/mixin_constants_test.rb
index 3dbe6cef..1276a58a 100644
--- a/test/bcdd/result/context/mixin_constants_test.rb
+++ b/test/bcdd/context/mixin_constants_test.rb
@@ -2,24 +2,24 @@
require 'test_helper'
-class BCDD::Result::Context::MixinConstantsTest < Minitest::Test
+class BCDD::Context::MixinConstantsTest < Minitest::Test
class IncludingInClass
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
end
module IncludingInModule
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
end
class ExtendingInClass
- extend BCDD::Result::Context.mixin
+ extend BCDD::Context.mixin
end
module ExtendingInModule
- extend BCDD::Result::Context.mixin
+ extend BCDD::Context.mixin
end
- test 'BCDD::Result::Context.mixin sets a constant in all classes/modules' do
+ test 'BCDD::Context.mixin sets a constant in all classes/modules' do
assert IncludingInClass.const_defined?(:ResultMixin, false)
assert IncludingInModule.const_defined?(:ResultMixin, false)
diff --git a/test/bcdd/result/context/success_test.rb b/test/bcdd/context/success_test.rb
similarity index 66%
rename from test/bcdd/result/context/success_test.rb
rename to test/bcdd/context/success_test.rb
index 52241a00..88b54834 100644
--- a/test/bcdd/result/context/success_test.rb
+++ b/test/bcdd/context/success_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextSuccessTest < Minitest::Test
- test 'is a BCDD::Result::Context' do
- assert Context::Success < BCDD::Result::Context
+ test 'is a BCDD::Context' do
+ assert Context::Success < BCDD::Context
end
test 'has BCDD::Result::Success::Methods' do
@@ -16,7 +16,7 @@ class ContextSuccessTest < Minitest::Test
result = Context::Success(:ok, number: 1)
assert_equal(
- '#1}>',
+ '#1}>',
result.inspect
)
end
diff --git a/test/bcdd/result/context/transitions/disabled/with_source/flat_test.rb b/test/bcdd/context/transitions/disabled/with_source/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/disabled/with_source/flat_test.rb
rename to test/bcdd/context/transitions/disabled/with_source/flat_test.rb
index 548980eb..ff218fda 100644
--- a/test/bcdd/result/context/transitions/disabled/with_source/flat_test.rb
+++ b/test/bcdd/context/transitions/disabled/with_source/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithSourceInstanceFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/disabled/with_source/nested_test.rb b/test/bcdd/context/transitions/disabled/with_source/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/disabled/with_source/nested_test.rb
rename to test/bcdd/context/transitions/disabled/with_source/nested_test.rb
index 2ed21997..0b4469f5 100644
--- a/test/bcdd/result/context/transitions/disabled/with_source/nested_test.rb
+++ b/test/bcdd/context/transitions/disabled/with_source/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithSourceInstanceNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/disabled/with_source/recursion_test.rb b/test/bcdd/context/transitions/disabled/with_source/recursion_test.rb
similarity index 96%
rename from test/bcdd/result/context/transitions/disabled/with_source/recursion_test.rb
rename to test/bcdd/context/transitions/disabled/with_source/recursion_test.rb
index 4a025f3b..f0fcf6b7 100644
--- a/test/bcdd/result/context/transitions/disabled/with_source/recursion_test.rb
+++ b/test/bcdd/context/transitions/disabled/with_source/recursion_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithSourceInstanceRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
@@ -15,7 +15,7 @@ def teardown
end
class Fibonacci
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(input)
BCDD::Result.transitions do
diff --git a/test/bcdd/result/context/transitions/disabled/without_source/flat_test.rb b/test/bcdd/context/transitions/disabled/without_source/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/disabled/without_source/flat_test.rb
rename to test/bcdd/context/transitions/disabled/without_source/flat_test.rb
index f9683b2f..b59862c8 100644
--- a/test/bcdd/result/context/transitions/disabled/without_source/flat_test.rb
+++ b/test/bcdd/context/transitions/disabled/without_source/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithoutSourceInstanceFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/disabled/without_source/nested_test.rb b/test/bcdd/context/transitions/disabled/without_source/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/disabled/without_source/nested_test.rb
rename to test/bcdd/context/transitions/disabled/without_source/nested_test.rb
index 6cc66306..c84a2e0d 100644
--- a/test/bcdd/result/context/transitions/disabled/without_source/nested_test.rb
+++ b/test/bcdd/context/transitions/disabled/without_source/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithoutSourceInstanceNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/disabled/without_source/recursion_test.rb b/test/bcdd/context/transitions/disabled/without_source/recursion_test.rb
similarity index 98%
rename from test/bcdd/result/context/transitions/disabled/without_source/recursion_test.rb
rename to test/bcdd/context/transitions/disabled/without_source/recursion_test.rb
index 3edd08f8..3d39539c 100644
--- a/test/bcdd/result/context/transitions/disabled/without_source/recursion_test.rb
+++ b/test/bcdd/context/transitions/disabled/without_source/recursion_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsDisabledWithoutSourceInstanceRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/not_been_started_test.rb b/test/bcdd/context/transitions/enabled/not_been_started_test.rb
similarity index 95%
rename from test/bcdd/result/context/transitions/enabled/not_been_started_test.rb
rename to test/bcdd/context/transitions/enabled/not_been_started_test.rb
index c8ab8332..f781f7ae 100644
--- a/test/bcdd/result/context/transitions/enabled/not_been_started_test.rb
+++ b/test/bcdd/context/transitions/enabled/not_been_started_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsNotBeenStartedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/instance/flat_test.rb b/test/bcdd/context/transitions/enabled/with_source/instance/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/with_source/instance/flat_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/instance/flat_test.rb
index f6279c87..89020ddf 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/instance/flat_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/instance/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceInstanceFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/instance/nested_test.rb b/test/bcdd/context/transitions/enabled/with_source/instance/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/with_source/instance/nested_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/instance/nested_test.rb
index 7a9e4106..575ec124 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/instance/nested_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/instance/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceInstanceNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/instance/recursion_test.rb b/test/bcdd/context/transitions/enabled/with_source/instance/recursion_test.rb
similarity index 95%
rename from test/bcdd/result/context/transitions/enabled/with_source/instance/recursion_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/instance/recursion_test.rb
index 06224fad..565fdbbd 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/instance/recursion_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/instance/recursion_test.rb
@@ -2,12 +2,12 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceInstanceRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
class Fibonacci
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(input)
BCDD::Result.transitions do
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/singleton/flat_test.rb b/test/bcdd/context/transitions/enabled/with_source/singleton/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/with_source/singleton/flat_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/singleton/flat_test.rb
index 804f7b92..870cf724 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/singleton/flat_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/singleton/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceSingletonFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/singleton/nested_test.rb b/test/bcdd/context/transitions/enabled/with_source/singleton/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/with_source/singleton/nested_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/singleton/nested_test.rb
index 5af49ead..92c20fcc 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/singleton/nested_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/singleton/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceSingletonNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/with_source/singleton/recursion_test.rb b/test/bcdd/context/transitions/enabled/with_source/singleton/recursion_test.rb
similarity index 95%
rename from test/bcdd/result/context/transitions/enabled/with_source/singleton/recursion_test.rb
rename to test/bcdd/context/transitions/enabled/with_source/singleton/recursion_test.rb
index 800892a4..b30fd188 100644
--- a/test/bcdd/result/context/transitions/enabled/with_source/singleton/recursion_test.rb
+++ b/test/bcdd/context/transitions/enabled/with_source/singleton/recursion_test.rb
@@ -2,12 +2,12 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithSourceSingletonRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
module Fibonacci
- extend self, BCDD::Result::Context.mixin
+ extend self, BCDD::Context.mixin
def call(input)
BCDD::Result.transitions do
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/instance/flat_test.rb b/test/bcdd/context/transitions/enabled/without_source/instance/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/without_source/instance/flat_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/instance/flat_test.rb
index de1abfa5..63624dd1 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/instance/flat_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/instance/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceInstanceFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/instance/nested_test.rb b/test/bcdd/context/transitions/enabled/without_source/instance/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/without_source/instance/nested_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/instance/nested_test.rb
index 0583812e..d2d11b53 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/instance/nested_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/instance/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceInstanceNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/instance/recursion_test.rb b/test/bcdd/context/transitions/enabled/without_source/instance/recursion_test.rb
similarity index 98%
rename from test/bcdd/result/context/transitions/enabled/without_source/instance/recursion_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/instance/recursion_test.rb
index 623c5bcf..b2b203fa 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/instance/recursion_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/instance/recursion_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceInstanceRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/singleton/flat_test.rb b/test/bcdd/context/transitions/enabled/without_source/singleton/flat_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/without_source/singleton/flat_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/singleton/flat_test.rb
index 59090717..3a89d44b 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/singleton/flat_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/singleton/flat_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceSingletonFlatTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/singleton/nested_test.rb b/test/bcdd/context/transitions/enabled/without_source/singleton/nested_test.rb
similarity index 99%
rename from test/bcdd/result/context/transitions/enabled/without_source/singleton/nested_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/singleton/nested_test.rb
index 20b975b5..aa6d7789 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/singleton/nested_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/singleton/nested_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceSingletonNestedTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context/transitions/enabled/without_source/singleton/recursion_test.rb b/test/bcdd/context/transitions/enabled/without_source/singleton/recursion_test.rb
similarity index 98%
rename from test/bcdd/result/context/transitions/enabled/without_source/singleton/recursion_test.rb
rename to test/bcdd/context/transitions/enabled/without_source/singleton/recursion_test.rb
index 108bcc0f..9c671cda 100644
--- a/test/bcdd/result/context/transitions/enabled/without_source/singleton/recursion_test.rb
+++ b/test/bcdd/context/transitions/enabled/without_source/singleton/recursion_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class Context::TransitionsEnabledWithoutSourceSingletonRecursionTest < Minitest::Test
include BCDDResultTransitionAssertions
diff --git a/test/bcdd/result/context_test.rb b/test/bcdd/context_test.rb
similarity index 98%
rename from test/bcdd/result/context_test.rb
rename to test/bcdd/context_test.rb
index fc755949..df84c12c 100644
--- a/test/bcdd/result/context_test.rb
+++ b/test/bcdd/context_test.rb
@@ -2,7 +2,7 @@
require 'test_helper'
-class BCDD::Result
+module BCDD
class ContextTest < Minitest::Test
test 'is a BCDD::Result' do
assert Context < BCDD::Result
diff --git a/test/bcdd/result/callable_and_then/returning_context_test.rb b/test/bcdd/result/callable_and_then/returning_context_test.rb
index ab12ab97..7ba4ba25 100644
--- a/test/bcdd/result/callable_and_then/returning_context_test.rb
+++ b/test/bcdd/result/callable_and_then/returning_context_test.rb
@@ -7,7 +7,7 @@ class CallableAndThenReturninContextTest < Minitest::Test
include BCDDResultTransitionAssertions
module NormalizeEmail
- extend Context.mixin
+ extend ::BCDD::Context.mixin
def self.call(arg)
BCDD::Result.transitions(name: 'NormalizeEmail') do
@@ -40,7 +40,7 @@ def self.call(input)
assert(result1.failure?(:invalid_input))
assert_equal({ message: 'input must be a String' }, result1.value)
- assert_kind_of(::BCDD::Result::Context, result1)
+ assert_kind_of(::BCDD::Context, result1)
result2 = EmailNormalization.call(' foo@BAR.com')
@@ -48,7 +48,7 @@ def self.call(input)
assert(result2.success?(:normalized_input))
assert_equal({ input: 'foo@bar.com' }, result2.value)
- assert_kind_of(::BCDD::Result::Context, result2)
+ assert_kind_of(::BCDD::Context, result2)
ensure
BCDD::Result.config.feature.disable!(:and_then!)
end
diff --git a/test/bcdd/result/config/addon/continue_test.rb b/test/bcdd/result/config/addon/continue_test.rb
index affb7cd2..704a462b 100644
--- a/test/bcdd/result/config/addon/continue_test.rb
+++ b/test/bcdd/result/config/addon/continue_test.rb
@@ -24,7 +24,7 @@ def call
end
class3a = Class.new do
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Continue(msg: "this method won't exist as the default config is disabled")
@@ -32,7 +32,7 @@ def call
end
class4a = Class.new do
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
def call
Continue(msg: "this method won't exist as the default config is disabled")
@@ -68,7 +68,7 @@ def call
end
class3b = Class.new do
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Continue(msg: 'this method will exist as the config is enabled by default')
@@ -76,7 +76,7 @@ def call
end
class4b = Class.new do
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
def call
Continue(msg: 'this method will exist as the config is enabled by default')
@@ -107,7 +107,7 @@ def call
end
class3c = Class.new do
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Continue(msg: "this method won't exist as the default config is disabled")
@@ -115,7 +115,7 @@ def call
end
class4c = Class.new do
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
def call
Continue(msg: "this method won't exist as the default config is disabled")
@@ -153,7 +153,7 @@ def call
end
class3 = Class.new do
- include BCDD::Result::Context.mixin(config: { addon: { continue: false } })
+ include BCDD::Context.mixin(config: { addon: { continue: false } })
def call
Continue(msg: "this method won't exist as the default config was overwritten")
@@ -161,7 +161,7 @@ def call
end
class4 = Class.new do
- include BCDD::Result::Context::Expectations.mixin(config: { addon: { continue: false } })
+ include BCDD::Context::Expectations.mixin(config: { addon: { continue: false } })
def call
Continue(msg: "this method won't exist as the default config was overwritten")
diff --git a/test/bcdd/result/config/addon/given_test.rb b/test/bcdd/result/config/addon/given_test.rb
index 1bb3ec95..e69ddd0f 100644
--- a/test/bcdd/result/config/addon/given_test.rb
+++ b/test/bcdd/result/config/addon/given_test.rb
@@ -24,7 +24,7 @@ def call
end
class3a = Class.new do
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
Given(msg: "this method won't exist as the default config is disabled")
@@ -32,7 +32,7 @@ def call
end
class4a = Class.new do
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
def call
Given(msg: "this method won't exist as the default config is disabled")
@@ -68,7 +68,7 @@ def call
end
class3b = Class.new do
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call
part1 = { part1: 'this method will exist' }
@@ -80,7 +80,7 @@ def call
end
class4b = Class.new do
- include BCDD::Result::Context::Expectations.mixin
+ include BCDD::Context::Expectations.mixin
def call
part1 = { part1: 'this method will exist' }
@@ -127,7 +127,7 @@ def call
end
class3 = Class.new do
- include BCDD::Result::Context.mixin(config: { addon: { given: false } })
+ include BCDD::Context.mixin(config: { addon: { given: false } })
def call
Given(msg: "this method won't exist as the default config was overwritten")
@@ -135,7 +135,7 @@ def call
end
class4 = Class.new do
- include BCDD::Result::Context::Expectations.mixin(config: { addon: { given: false } })
+ include BCDD::Context::Expectations.mixin(config: { addon: { given: false } })
def call
Given(msg: "this method won't exist as the default config was overwritten")
diff --git a/test/bcdd/result/config/addon_test.rb b/test/bcdd/result/config/addon_test.rb
index 898dee60..b6e809ca 100644
--- a/test/bcdd/result/config/addon_test.rb
+++ b/test/bcdd/result/config/addon_test.rb
@@ -6,9 +6,9 @@ class BCDD::Result::Config
class AddonTest < Minitest::Test
AFFECTS = [
'BCDD::Result.mixin',
- 'BCDD::Result::Context.mixin',
+ 'BCDD::Context.mixin',
'BCDD::Result::Expectations.mixin',
- 'BCDD::Result::Context::Expectations.mixin'
+ 'BCDD::Context::Expectations.mixin'
].freeze
test 'the switcher' do
diff --git a/test/bcdd/result/config/constant_alias/result_test.rb b/test/bcdd/result/config/constant_alias/result_test.rb
index 6e8dfe1d..cebf02a8 100644
--- a/test/bcdd/result/config/constant_alias/result_test.rb
+++ b/test/bcdd/result/config/constant_alias/result_test.rb
@@ -15,29 +15,5 @@ class ConstantAliasResultTest < Minitest::Test
assert_raises(NameError) { ::Result }
end
-
- test 'the side effects (Context)' do
- assert_raises(NameError) { ::Context }
-
- BCDD::Result.config.constant_alias.enable!('Context')
-
- assert_same(BCDD::Result::Context, ::Context)
- ensure
- BCDD::Result.config.constant_alias.disable!('Context')
-
- assert_raises(NameError) { ::Context }
- end
-
- test 'the side effects (BCDD::Context)' do
- assert_raises(NameError) { ::BCDD::Context }
-
- BCDD::Result.config.constant_alias.enable!('BCDD::Context')
-
- assert_same(BCDD::Result::Context, ::BCDD::Context)
- ensure
- BCDD::Result.config.constant_alias.disable!('BCDD::Context')
-
- assert_raises(NameError) { ::BCDD::Context }
- end
end
end
diff --git a/test/bcdd/result/config/constant_alias_test.rb b/test/bcdd/result/config/constant_alias_test.rb
index 4920d8d9..e2378d94 100644
--- a/test/bcdd/result/config/constant_alias_test.rb
+++ b/test/bcdd/result/config/constant_alias_test.rb
@@ -11,9 +11,7 @@ class ConstantAliasTest < Minitest::Test
assert_equal(
{
- 'Result' => { enabled: false, affects: ['Object'] },
- 'Context' => { enabled: false, affects: ['Object'] },
- 'BCDD::Context' => { enabled: false, affects: ['BCDD'] }
+ 'Result' => { enabled: false, affects: ['Object'] }
},
config.options
)
diff --git a/test/bcdd/result/config/feature/and_then_bang_test.rb b/test/bcdd/result/config/feature/and_then_bang_test.rb
index 2eb2f2ee..32ba4752 100644
--- a/test/bcdd/result/config/feature/and_then_bang_test.rb
+++ b/test/bcdd/result/config/feature/and_then_bang_test.rb
@@ -27,7 +27,7 @@ def self.perform(value)
end
class AddC
- include BCDD::Result::Context.mixin
+ include BCDD::Context.mixin
def call(number1:, number2:)
Success(:ok, number: number1 + number2)
diff --git a/test/bcdd/result/config/feature/expectations_test.rb b/test/bcdd/result/config/feature/expectations_test.rb
index 15ea049a..31c43687 100644
--- a/test/bcdd/result/config/feature/expectations_test.rb
+++ b/test/bcdd/result/config/feature/expectations_test.rb
@@ -16,13 +16,13 @@ def call; Success(:ok, '1'); end
class1b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, '1'); end }
class1c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
+ include BCDD::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
def call; Success(:yes, one: 1); end
end
class1d = Class.new
- class1d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
+ class1d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
class1d.class_eval { def call; self.class.const_get(:Result, false)::Success(:yes, one: 1); end }
assert_raises(BCDD::Result::Contract::Error::UnexpectedValue) { class1a.new.call }
@@ -48,13 +48,13 @@ def call; Success(:ok, '1'); end
class2b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, '1'); end }
class2c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
+ include BCDD::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
def call; Success(:yes, one: 1); end
end
class2d = Class.new
- class2d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
+ class2d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
class2d.class_eval { def call; self.class.const_get(:Result, false)::Success(:yes, one: 1); end }
assert(class2a.new.call.then { _1.success?(:ok) && _1.value == '1' })
@@ -80,13 +80,13 @@ def call; Success(:ok, '1'); end
class3b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, '1'); end }
class3c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
+ include BCDD::Context::Expectations.mixin(success: { ok: ->(v) { v[:one] == 1 } })
def call; Success(:yes, one: 1); end
end
class3d = Class.new
- class3d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
+ class3d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: ->(v) { v[:one] == 1 } }))
class3d.class_eval { def call; self.class.const_get(:Result, false)::Success(:yes, one: 1); end }
assert_raises(BCDD::Result::Contract::Error::UnexpectedValue) { class3a.new.call }
diff --git a/test/bcdd/result/config/feature_test.rb b/test/bcdd/result/config/feature_test.rb
index f4fbeafd..259bcf24 100644
--- a/test/bcdd/result/config/feature_test.rb
+++ b/test/bcdd/result/config/feature_test.rb
@@ -13,13 +13,13 @@ class FeatureInstanceTest < Minitest::Test
{
expectations: {
enabled: true,
- affects: ['BCDD::Result::Expectations', 'BCDD::Result::Context::Expectations']
+ affects: ['BCDD::Result::Expectations', 'BCDD::Context::Expectations']
},
transitions: { enabled: true, affects: %w[
- BCDD::Result BCDD::Result::Context BCDD::Result::Expectations BCDD::Result::Context::Expectations
+ BCDD::Result BCDD::Context BCDD::Result::Expectations BCDD::Context::Expectations
] },
and_then!: { enabled: false, affects: %w[
- BCDD::Result BCDD::Result::Context BCDD::Result::Expectations BCDD::Result::Context::Expectations
+ BCDD::Result BCDD::Context BCDD::Result::Expectations BCDD::Context::Expectations
] }
},
config.options
diff --git a/test/bcdd/result/config/pattern_matching/nil_as_valid_value_checking_test.rb b/test/bcdd/result/config/pattern_matching/nil_as_valid_value_checking_test.rb
index 8bb0c0ee..27a590ef 100644
--- a/test/bcdd/result/config/pattern_matching/nil_as_valid_value_checking_test.rb
+++ b/test/bcdd/result/config/pattern_matching/nil_as_valid_value_checking_test.rb
@@ -32,13 +32,13 @@ def call; Success(:ok, 1); end
class1b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, 1); end }
class1c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: is_hash_numeric })
+ include BCDD::Context::Expectations.mixin(success: { ok: is_hash_numeric })
def call; Success(:ok, number: 1); end
end
class1d = Class.new
- class1d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: is_hash_numeric }))
+ class1d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: is_hash_numeric }))
class1d.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, number: 1); end }
assert_raises(BCDD::Result::Contract::Error::UnexpectedValue) { class1a.new.call }
@@ -64,13 +64,13 @@ def call; Success(:ok, 1); end
class2b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, 1); end }
class2c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: is_hash_numeric })
+ include BCDD::Context::Expectations.mixin(success: { ok: is_hash_numeric })
def call; Success(:ok, number: 1); end
end
class2d = Class.new
- class2d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: is_hash_numeric }))
+ class2d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: is_hash_numeric }))
class2d.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, number: 1); end }
assert(class2a.new.call.then { _1.success?(:ok) && _1.value == 1 })
@@ -101,13 +101,13 @@ def call; Success(:ok, 1); end
class3b.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, 1); end }
class3c = Class.new do
- include BCDD::Result::Context::Expectations.mixin(success: { ok: is_hash_numeric })
+ include BCDD::Context::Expectations.mixin(success: { ok: is_hash_numeric })
def call; Success(:ok, number: 1); end
end
class3d = Class.new
- class3d.const_set(:Result, BCDD::Result::Context::Expectations.new(success: { ok: is_hash_numeric }))
+ class3d.const_set(:Result, BCDD::Context::Expectations.new(success: { ok: is_hash_numeric }))
class3d.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, number: 1); end }
assert_raises(BCDD::Result::Contract::Error::UnexpectedValue) { class3a.new.call }
@@ -160,7 +160,7 @@ def call; Success(:ok, 1); end
class2.class_eval { def call; self.class.const_get(:Result, false)::Success(:ok, 1); end }
class3 = Class.new do
- include BCDD::Result::Context::Expectations.mixin(
+ include BCDD::Context::Expectations.mixin(
config: { pattern_matching: { nil_as_valid_value_checking: false } },
success: { ok: is_hash_numeric }
)
@@ -171,7 +171,7 @@ def call; Success(:ok, number: 1); end
class4 = Class.new
class4.const_set(
:Result,
- BCDD::Result::Context::Expectations.new(
+ BCDD::Context::Expectations.new(
config: { pattern_matching: { nil_as_valid_value_checking: false } },
success: { ok: is_hash_numeric }
)
diff --git a/test/bcdd/result/config/pattern_matching_test.rb b/test/bcdd/result/config/pattern_matching_test.rb
index 8a858839..712747f7 100644
--- a/test/bcdd/result/config/pattern_matching_test.rb
+++ b/test/bcdd/result/config/pattern_matching_test.rb
@@ -15,7 +15,7 @@ class PatternMatchingTest < Minitest::Test
enabled: false,
affects: [
'BCDD::Result::Expectations',
- 'BCDD::Result::Context::Expectations'
+ 'BCDD::Context::Expectations'
]
}
},
diff --git a/test/bcdd/result/config_test.rb b/test/bcdd/result/config_test.rb
index 786b3903..6e70dc2e 100644
--- a/test/bcdd/result/config_test.rb
+++ b/test/bcdd/result/config_test.rb
@@ -50,7 +50,7 @@ class Test < Minitest::Test
assert_equal({ continue: false, given: true }, config_values[:addon])
assert_equal({ expectations: true, transitions: true, and_then!: false }, config_values[:feature])
assert_equal({ nil_as_valid_value_checking: false }, config_values[:pattern_matching])
- assert_equal({ 'Result' => false, 'Context' => false, 'BCDD::Context' => false }, config_values[:constant_alias])
+ assert_equal({ 'Result' => false }, config_values[:constant_alias])
BCDD::Result.config.options.each do |key, switcher|
assert_equal(switcher.to_h, config_values[key])
diff --git a/test/bcdd/result/contract/nil_as_valid_value_checking_test.rb b/test/bcdd/result/contract/nil_as_valid_value_checking_test.rb
index c27a9f77..25702280 100644
--- a/test/bcdd/result/contract/nil_as_valid_value_checking_test.rb
+++ b/test/bcdd/result/contract/nil_as_valid_value_checking_test.rb
@@ -31,7 +31,7 @@ class Contract::NiltAsValidValueCheckingTest < Minitest::Test
BCDD::Result.config.pattern_matching.disable!(:nil_as_valid_value_checking)
end
- test 'BCDD::Result::Context::Expectations' do
+ test 'BCDD::Context::Expectations' do
contract = {
ok: ->(value) {
case value
@@ -40,7 +40,7 @@ class Contract::NiltAsValidValueCheckingTest < Minitest::Test
}
}
- _Result1 = BCDD::Result::Context::Expectations.new(success: contract)
+ _Result1 = BCDD::Context::Expectations.new(success: contract)
assert_raises(Contract::Error::UnexpectedValue) do
_Result1::Success(:ok, number: 1)
@@ -48,7 +48,7 @@ class Contract::NiltAsValidValueCheckingTest < Minitest::Test
BCDD::Result.config.pattern_matching.enable!(:nil_as_valid_value_checking)
- _Result2 = BCDD::Result::Context::Expectations.new(success: contract)
+ _Result2 = BCDD::Context::Expectations.new(success: contract)
result = _Result2::Success(:ok, number: 1)