Module: Fix
- Defined in:
- lib/fix.rb,
lib/fix/doc.rb,
lib/fix/dsl.rb,
lib/fix/run.rb,
lib/fix/set.rb,
lib/fix/matcher.rb,
lib/fix/requirement.rb,
lib/fix/error/missing_subject_block.rb,
lib/fix/error/specification_not_found.rb,
lib/fix/error/invalid_specification_name.rb,
lib/fix/error/missing_specification_block.rb
Overview
The Fix framework namespace provides core functionality for managing and running test specifications. Fix offers a unique approach to testing by clearly separating specifications from their implementations.
Fix supports two primary modes of operation:
-
Named specifications that can be stored and referenced later
-
Anonymous specifications for immediate one-time testing
Available matchers through the Matchi library include:
-
Basic Comparison: eq, eql, be, equal
-
Type Checking: be_an_instance_of, be_a_kind_of
-
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_*, have_* (e.g., be_empty, have_key)
Defined Under Namespace
Modules: Doc, Error, Matcher, Requirement Classes: Dsl, Run, Set
Class Method Summary collapse
-
.[](name) ⇒ Fix::Set
Retrieves a previously registered specification by name.
-
.key?(name) ⇒ Boolean
Checks if a specification is registered under the given name.
-
.keys ⇒ Array<Symbol>
Lists all defined specification names.
-
.spec(name = nil, &block) ⇒ Fix::Set
Creates a new specification set, optionally registering it under a name.
Class Method Details
.[](name) ⇒ Fix::Set
Retrieves a previously registered specification by name.
141 142 143 144 145 |
# File 'lib/fix.rb', line 141 def self.[](name) raise Error::SpecificationNotFound, name unless key?(name) Set.load(name) end |
.key?(name) ⇒ Boolean
Checks if a specification is registered under the given name.
176 177 178 |
# File 'lib/fix.rb', line 176 def self.key?(name) keys.include?(name) end |
.keys ⇒ Array<Symbol>
Lists all defined specification names.
158 159 160 |
# File 'lib/fix.rb', line 158 def self.keys Doc.constants.sort end |
.spec(name = nil, &block) ⇒ Fix::Set
Creates a new specification set, optionally registering it under a name.
111 112 113 114 115 |
# File 'lib/fix.rb', line 111 def self.spec(name = nil, &block) raise Error::MissingSpecificationBlock if block.nil? Set.build(name, &block) end |