Module: Kernel
- Defined in:
- lib/kernel.rb
Overview
Extension of the global Kernel module to provide the Fix method. This module provides a global entry point to the Fix testing framework, allowing specifications to be defined and managed from anywhere in the application.
The Fix method can be used in two main ways:
-
Creating named specifications for reuse
-
Creating anonymous specifications for immediate testing
Instance Method Summary collapse
-
#Fix(name = nil) { ... } ⇒ Fix::Set
Defines a new test specification or creates an anonymous specification set.
Instance Method Details
#Fix(name = nil) { ... } ⇒ Fix::Set
Defines a new test specification or creates an anonymous specification set. When a name is provided, the specification is registered globally and can be referenced later using Fix. Anonymous specifications are executed immediately and cannot be referenced later.
Specifications can use three levels of requirements, following RFC 2119:
-
MUST/MUST_NOT: Absolute requirements or prohibitions
-
SHOULD/SHOULD_NOT: Strong recommendations that can be ignored with good reason
-
MAY: Optional features that can be implemented or not
Available matchers include:
-
Basic Comparison: eq(expected), eql(expected), be(expected), equal(expected)
-
Type Checking: be_an_instance_of(class), be_a_kind_of(class)
-
State & Changes: change(object, method).by(n), by_at_least(n), by_at_most(n),
from(old).to(new), to(new)
-
Value Testing: be_within(delta).of(value), match(regex),
satisfy { |value| ... }
-
Exceptions: raise_exception(class)
-
State Testing: be_true, be_false, be_nil
-
Predicate Matchers: be_* (e.g., be_empty), have_* (e.g., have_key)
98 99 100 |
# File 'lib/kernel.rb', line 98 def Fix(name = nil, &block) ::Fix.spec(name, &block) end |