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/builder.rb,
lib/fix/matcher.rb,
lib/fix/requirement.rb,
lib/fix/error/specification_not_found.rb,
lib/fix/error/invalid_specification_name.rb,
lib/fix/error/missing_specification_block.rb

Overview

Namespace for the Fix framework.

Provides core functionality for managing and running test specifications. Fix supports two modes of operation:

  1. Named specifications that can be referenced later

  2. Anonymous specifications for immediate testing

Examples:

Creating and running a named specification

Fix :Answer do
  it MUST equal 42
end

Fix[:Answer].test { 42 }

Creating and running an anonymous specification

Fix do
  it MUST be_positive
end.test { 42 }

See Also:

Defined Under Namespace

Modules: Doc, Error, Matcher, Requirement Classes: Builder, Dsl, Run, Set

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Fix::Set

Retrieves and loads a built specification for testing.

Examples:

Run a named specification

Fix[:Answer].test { 42 }

Parameters:

  • name (String, Symbol)

    The constant name of the specification

Returns:

  • (Fix::Set)

    The loaded specification set ready for testing

Raises:



41
42
43
44
45
# File 'lib/fix.rb', line 41

def [](name)
  name = normalize_name(name)
  validate_specification_exists!(name)
  Set.load(name)
end

.spec_defined?(name) ⇒ Boolean

Checks if a specification is defined.

Examples:

Check for specification existence

Fix.spec_defined?(:Answer) #=> true

Parameters:

  • name (String, Symbol)

    Name of the specification to check

Returns:

  • (Boolean)

    true if specification exists, false otherwise



64
65
66
# File 'lib/fix.rb', line 64

def spec_defined?(name)
  specification_names.include?(normalize_name(name))
end

.specification_namesArray<Symbol>

Lists all defined specification names.

Examples:

Get all specification names

Fix.specification_names #=> [:Answer, :Calculator, :UserProfile]

Returns:

  • (Array<Symbol>)

    Sorted array of specification names



53
54
55
# File 'lib/fix.rb', line 53

def specification_names
  Doc.constants.sort
end