module Expected::Matchers

Matchers container

Public Instance Methods

be_a_concern() click to toggle source

Used to test inheritance @return [BeAConcernMatcher]

@example Test if the subject is an ActiveSupport::Concern

it { is_expected.to be_a_concern }
# File lib/expected/matchers/be_a_concern.rb, line 15
def be_a_concern
  BeAConcernMatcher.new
end
extend_module(expected_module) click to toggle source

Used to test inheritance @param expected_module [Class] @return [ExtendModuleMatcher]

@example Test if the subject extends the supplied Module

it { is_expected.to extend(SomeClass) }
# File lib/expected/matchers/extend_module.rb, line 14
def extend_module(expected_module)
  ExtendModuleMatcher.new(expected_module)
end
have_attr_accessor(attribute) click to toggle source

Used to test inclusion of `attr_accessor :attribute` on the subject @param attribute [String, Symbol] @return [HaveAttrAccessorMatcher]

@example Test if the subject has `attr_accessor :attribute`

it { is_expected.to have_attr_accessor(:some_attribute) }
# File lib/expected/matchers/have_attr_accessor.rb, line 18
def have_attr_accessor(attribute) # rubocop:disable Naming/PredicateName
  HaveAttrAccessorMatcher.new(attribute)
end
have_attr_reader(attribute) click to toggle source

Used to test inclusion of `attr_reader :attribute` on the subject @param attribute [String, Symbol] @return [HaveAttrReaderMatcher]

@example Test if the subject has `attr_reader :attribute`

it { is_expected.to have_attr_reader(:some_attribute) }
# File lib/expected/matchers/have_attr_reader.rb, line 16
def have_attr_reader(attribute) # rubocop:disable Naming/PredicateName
  HaveAttrReaderMatcher.new(attribute)
end
have_attr_writer(attribute) click to toggle source

Used to test inclusion of `attr_writer :attribute` on the subject @param attribute [String, Symbol] @return [HaveAttrWriterMatcher]

@example Test if the subject has `attr_writer :attribute`

it { is_expected.to have_attr_writer(:some_attribute) }
# File lib/expected/matchers/have_attr_writer.rb, line 16
def have_attr_writer(attribute) # rubocop:disable Naming/PredicateName
  HaveAttrWriterMatcher.new(attribute)
end
have_constant(name) click to toggle source

Used to test constants @param name [String, Symbol] @return [HaveConstantMatcher]

@example Test if a constant exists

it { is_expected.to have_constant(:FOO) }

@example Test if a constant has a specific value

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

@example Test if a constant's value is a specific type

it { is_expected.to have_constant(:FOO).of_type(String) }
# File lib/expected/matchers/have_constant.rb, line 20
def have_constant(name) # rubocop:disable Naming/PredicateName
  HaveConstantMatcher.new(name)
end
include_module(expected_module) click to toggle source

Used to test inheritance @param expected_module [Module] @return [IncludeModuleMatcher]

@example Test if the subject includes the supplied Module

it { is_expected.to include_module(SomeModule) }
# File lib/expected/matchers/include_module.rb, line 14
def include_module(expected_module)
  IncludeModuleMatcher.new(expected_module)
end
inherit_from(expected_ancestor) click to toggle source

Used to test inheritance @param expected_ancestor [Class] @return [InheritFromMatcher]

@example Test if the subject inherits from the supplied Class

it { is_expected.to inherit_from(SomeClass) }
# File lib/expected/matchers/inherit_from.rb, line 14
def inherit_from(expected_ancestor)
  InheritFromMatcher.new(expected_ancestor)
end