Method: Expected::Matchers#have_constant

Defined in:
lib/expected/matchers/have_constant.rb

#have_constant(name) ⇒ HaveConstantMatcher

Used to test constants

Examples:

Test if a constant exists

it { is_expected.to have_constant(:FOO) }

Test if a constant has a specific value

it { is_expected.to have_constant(:FOO).with_value("bar") }

Test if a constant’s value is a specific type

it { is_expected.to have_constant(:FOO).of_type(String) }

Parameters:

  • name (String, Symbol)

Returns:



20
21
22
# File 'lib/expected/matchers/have_constant.rb', line 20

def have_constant(name) # rubocop:disable Naming/PredicateName
  HaveConstantMatcher.new(name)
end