module RSpec::SleepingKingStudios::Matchers::Macros

Public Class Methods

alias_matcher(new_name, old_name, options = {}, &description_override) click to toggle source

@see RSpec::Matchers::alias_matcher

# File lib/rspec/sleeping_king_studios/matchers/macros.rb, line 8
def self.alias_matcher(new_name, old_name, options = {}, &description_override)
  description_override ||= if defined?(RSpec::Matchers::Pretty)
    ->(str) { str.gsub(RSpec::Matchers::Pretty.split_words(old_name), RSpec::Matchers::Pretty.split_words(new_name)) }
  elsif defined?(RSpec::Matchers::EnglishPhrasing)
    ->(str) { str.gsub(RSpec::Matchers::EnglishPhrasing.split_words(old_name), RSpec::Matchers::EnglishPhrasing.split_words(new_name)) }
  else
    ->(str) { str }
  end # if-elsif-else

  klass = (options.is_a?(Hash) ? options[:klass] : nil) || RSpec::Matchers::AliasedMatcher
  define_method(new_name) do |*args, &block|
    matcher = __send__(old_name, *args, &block)

    klass.new(matcher, description_override)
  end # define_method
end

Public Instance Methods

alias_method(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::AliasMethodMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/alias_method.rb, line 8
def alias_method expected
  SleepingKingStudios::Tools::CoreTools.deprecate(
    '#alias_method',
    message: 'Use #have_aliased_method instead.'
  )

  RSpec::SleepingKingStudios::Matchers::Core::HaveAliasedMethodMatcher
    .new expected
end
be_a(expected)
Alias for: be_kind_of
be_a_uuid() click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::BeAUuidMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/be_a_uuid.rb, line 8
def be_a_uuid
  RSpec::SleepingKingStudios::Matchers::Core::BeAUuidMatcher.new
end
be_bool()
Alias for: be_boolean
be_boolean() click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::BeBooleanMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/be_boolean.rb, line 8
def be_boolean
  RSpec::SleepingKingStudios::Matchers::Core::BeBooleanMatcher.new
end
Also aliased as: be_bool
be_constructible()
Alias for: construct
be_kind_of(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::BuiltIn::BeAKindOfMatcher#match

# File lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of.rb, line 8
def be_kind_of expected
  RSpec::SleepingKingStudios::Matchers::BuiltIn::BeAKindOfMatcher.new expected
end
Also aliased as: be_a
construct() click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::ConstructMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/construct.rb, line 8
def construct
  RSpec::SleepingKingStudios::Matchers::Core::ConstructMatcher.new
end
Also aliased as: be_constructible
deep_match(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::BeBooleanMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/deep_match.rb, line 8
def deep_match(expected)
  RSpec::SleepingKingStudios::Matchers::Core::DeepMatcher.new(expected)
end
define_constant(expected)
Alias for: have_constant
define_immutable_constant(expected)
define_predicate(expected)
Alias for: have_predicate
define_property(expected, allow_private: false)
Alias for: have_property
define_reader(expected, allow_private: false)
Alias for: have_reader
define_writer(expected, allow_private: false)
Alias for: have_writer
delegate_method(*method_names) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::DelegateMethodMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/delegate_method.rb, line 8
def delegate_method *method_names
  RSpec::SleepingKingStudios::Matchers::Core::DelegateMethodMatcher.new *method_names
end
have_aliased_method(original_name) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveAliasedMethodMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method.rb, line 8
def have_aliased_method(original_name)
  RSpec::SleepingKingStudios::Matchers::Core::HaveAliasedMethodMatcher
    .new(original_name)
end
have_changed() click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveChangedMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_changed.rb, line 7
def have_changed
  RSpec::SleepingKingStudios::Matchers::Core::HaveChangedMatcher.new
end
have_constant(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveConstantMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_constant.rb, line 8
def have_constant expected
  RSpec::SleepingKingStudios::Matchers::Core::HaveConstantMatcher.new expected
end
Also aliased as: define_constant
have_errors() click to toggle source

@see RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrorsMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/active_model/have_errors.rb, line 8
def have_errors
  RSpec::SleepingKingStudios::Matchers::ActiveModel::HaveErrorsMatcher.new
end
have_immutable_constant(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveConstantMatcher#immutable

# File lib/rspec/sleeping_king_studios/matchers/core/have_constant.rb, line 14
def have_immutable_constant expected
  have_constant(expected).immutable
end
Also aliased as: define_immutable_constant
have_predicate(expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HavePredicateMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_predicate.rb, line 8
def have_predicate expected
  RSpec::SleepingKingStudios::Matchers::Core::HavePredicateMatcher.new expected
end
Also aliased as: define_predicate
have_property(expected, allow_private: false) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HavePropertyMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_property.rb, line 8
def have_property expected, allow_private: false
  RSpec::SleepingKingStudios::Matchers::Core::HavePropertyMatcher.new(
    expected,
    :allow_private => allow_private
  ) # end matcher
end
Also aliased as: define_property
have_reader(expected, allow_private: false) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveReaderMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_reader.rb, line 8
def have_reader expected, allow_private: false
  RSpec::SleepingKingStudios::Matchers::Core::HaveReaderMatcher.new(
    expected,
    :allow_private => allow_private
  ) # end matcher
end
Also aliased as: define_reader
have_writer(expected, allow_private: false) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::Core::HaveWriterMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/core/have_writer.rb, line 8
def have_writer expected, allow_private: false
  RSpec::SleepingKingStudios::Matchers::Core::HaveWriterMatcher.new(
    expected,
    :allow_private => allow_private
  ) # end matcher
end
Also aliased as: define_writer
include(*expected, &block) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::BuiltIn::IncludeMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/built_in/include.rb, line 8
def include *expected, &block
  RSpec::SleepingKingStudios::Matchers::BuiltIn::IncludeMatcher.new *expected, &block
end
respond_to(*expected) click to toggle source

@see RSpec::SleepingKingStudios::Matchers::BuiltIn::RespondToMatcher#matches?

# File lib/rspec/sleeping_king_studios/matchers/built_in/respond_to.rb, line 8
def respond_to *expected
  RSpec::SleepingKingStudios::Matchers::BuiltIn::RespondToMatcher.new *expected
end
watch_value(object = nil, method_name = nil, &block) click to toggle source

@see RSpec::SleepingKingStudios::Support::ValueSpy#initialize

# File lib/rspec/sleeping_king_studios/matchers/core/have_changed.rb, line 12
def watch_value(object = nil, method_name = nil, &block)
  RSpec::SleepingKingStudios::Support::ValueSpy
    .new(object, method_name, &block)
end