Class: Fix::Dsl Private
- Inherits:
-
Object
- Object
- Fix::Dsl
- Extended by:
- Matcher, Requirement
- Defined in:
- lib/fix/dsl.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Abstract class for handling the domain-specific language.
Class Method Summary collapse
-
.challenges ⇒ Array<Defi::Method>
private
The list of challenges to be addressed to the object to be tested.
-
.it(requirement) ⇒ Object
Defines a concrete spec definition.
-
.let(name) { ... } ⇒ Symbol
Sets a user-defined property.
-
.on(method_name, *args, **kwargs, &block) ⇒ Object
Defines an example group that describes a unit to be tested.
-
.with(**kwargs) { ... } ⇒ Object
Defines an example group with user-defined properties that describes a unit to be tested.
Methods included from Matcher
be, be_an_instance_of, be_false, be_nil, be_true, be_within, change, eq, match, raise_exception, satisfy
Methods included from Requirement
MAY, MUST, MUST_NOT, SHOULD, SHOULD_NOT
Class Method Details
.challenges ⇒ Array<Defi::Method>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The list of challenges to be addressed to the object to be tested.
111 112 113 |
# File 'lib/fix/dsl.rb', line 111 def self.challenges [] end |
.it(requirement) ⇒ Object
Defines a concrete spec definition.
99 100 101 102 103 104 105 106 |
# File 'lib/fix/dsl.rb', line 99 def self.it(requirement) location = caller_locations(1, 1).fetch(0) location = [location.path, location.lineno].join(":") define_method(:"test_#{requirement.object_id}") do [location, requirement, self.class.challenges] end end |
.let(name) { ... } ⇒ Symbol
Sets a user-defined property.
32 33 34 |
# File 'lib/fix/dsl.rb', line 32 def self.let(name, &) private define_method(name, &) end |
.on(method_name, *args, **kwargs, &block) ⇒ Object
Defines an example group that describes a unit to be tested.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fix/dsl.rb', line 76 def self.on(method_name, *args, **kwargs, &block) klass = ::Class.new(self) klass.const_get(:CONTEXTS) << klass const_set(:"Child#{block.object_id}", klass) klass.define_singleton_method(:challenges) do challenge = ::Defi::Method.new(method_name, *args, **kwargs) super() + [challenge] end klass.instance_eval(&block) klass end |
.with(**kwargs) { ... } ⇒ Object
Defines an example group with user-defined properties that describes a unit to be tested.
53 54 55 56 57 58 59 |
# File 'lib/fix/dsl.rb', line 53 def self.with(**kwargs, &) klass = ::Class.new(self) klass.const_get(:CONTEXTS) << klass kwargs.each { |name, value| klass.let(name) { value } } klass.instance_eval(&) klass end |