Module: RSpec::SleepingKingStudios::Matchers::Macros
- Included in:
- RSpec::SleepingKingStudios::Matchers
- Defined in:
- lib/rspec/sleeping_king_studios/matchers/macros.rb,
lib/rspec/sleeping_king_studios/matchers/core/be_a_uuid.rb,
lib/rspec/sleeping_king_studios/matchers/core/construct.rb,
lib/rspec/sleeping_king_studios/matchers/core/be_boolean.rb,
lib/rspec/sleeping_king_studios/matchers/core/deep_match.rb,
lib/rspec/sleeping_king_studios/matchers/built_in/include.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_reader.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_writer.rb,
lib/rspec/sleeping_king_studios/matchers/core/alias_method.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_changed.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_constant.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_property.rb,
lib/rspec/sleeping_king_studios/matchers/built_in/be_kind_of.rb,
lib/rspec/sleeping_king_studios/matchers/built_in/respond_to.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_predicate.rb,
lib/rspec/sleeping_king_studios/matchers/core/delegate_method.rb,
lib/rspec/sleeping_king_studios/matchers/active_model/have_errors.rb,
lib/rspec/sleeping_king_studios/matchers/core/have_aliased_method.rb
Class Method Summary collapse
Instance Method Summary collapse
- #a_boolean ⇒ Object
- #a_uuid ⇒ Object
- #alias_method(expected) ⇒ Object
- #be_a_uuid ⇒ Object
- #be_boolean ⇒ Object (also: #be_bool)
- #be_kind_of(expected) ⇒ Object (also: #be_a)
- #construct ⇒ Object (also: #be_constructible)
- #deep_match(expected) ⇒ Object
- #delegate_method(*method_names) ⇒ Object
- #have_aliased_method(original_name) ⇒ Object
- #have_changed ⇒ Object
- #have_constant(expected) ⇒ Object (also: #define_constant)
- #have_errors ⇒ Object
- #have_immutable_constant(expected) ⇒ Object (also: #define_immutable_constant)
- #have_predicate(expected) ⇒ Object (also: #define_predicate)
- #have_property(expected, allow_private: false) ⇒ Object (also: #define_property)
- #have_reader(expected, allow_private: false) ⇒ Object (also: #define_reader)
- #have_writer(expected, allow_private: false) ⇒ Object (also: #define_writer)
- #include(*expected, &block) ⇒ Object
- #respond_to(*expected) ⇒ Object
- #watch_value(object = nil, method_name = nil, &block) ⇒ Object
Class Method Details
.alias_matcher(new_name, old_name, options = {}, &description_override) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec/sleeping_king_studios/matchers/macros.rb', line 8 def self.alias_matcher(new_name, old_name, = {}, &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 = (.is_a?(Hash) ? [: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 |
Instance Method Details
#a_boolean ⇒ Object
16 17 18 |
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean.rb', line 16 alias_matcher :a_boolean, :be_boolean do |description| 'true or false' end |
#a_uuid ⇒ Object
14 15 16 |
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_a_uuid.rb', line 14 alias_matcher :a_uuid, :be_a_uuid do |description| 'a UUID' end |
#alias_method(expected) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# 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_uuid ⇒ Object
8 9 10 |
# 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_boolean ⇒ Object Also known as: be_bool
8 9 10 |
# File 'lib/rspec/sleeping_king_studios/matchers/core/be_boolean.rb', line 8 def be_boolean RSpec::SleepingKingStudios::Matchers::Core::BeBooleanMatcher.new end |
#be_kind_of(expected) ⇒ Object Also known as: be_a
8 9 10 |
# 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 |
#construct ⇒ Object Also known as: be_constructible
8 9 10 |
# File 'lib/rspec/sleeping_king_studios/matchers/core/construct.rb', line 8 def construct RSpec::SleepingKingStudios::Matchers::Core::ConstructMatcher.new end |
#deep_match(expected) ⇒ Object
8 9 10 |
# 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 |
#delegate_method(*method_names) ⇒ Object
8 9 10 |
# 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) ⇒ Object
8 9 10 11 |
# 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 ⇒ Object
7 8 9 |
# 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) ⇒ Object Also known as: define_constant
8 9 10 |
# 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 |
#have_errors ⇒ Object
8 9 10 |
# 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) ⇒ Object Also known as: define_immutable_constant
14 15 16 |
# File 'lib/rspec/sleeping_king_studios/matchers/core/have_constant.rb', line 14 def have_immutable_constant expected have_constant(expected).immutable end |
#have_predicate(expected) ⇒ Object Also known as: define_predicate
8 9 10 |
# 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 |
#have_property(expected, allow_private: false) ⇒ Object Also known as: define_property
8 9 10 11 12 13 |
# 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 |
#have_reader(expected, allow_private: false) ⇒ Object Also known as: define_reader
8 9 10 11 12 13 |
# 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 |
#have_writer(expected, allow_private: false) ⇒ Object Also known as: define_writer
8 9 10 11 12 13 |
# 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 |
#include(*expected, &block) ⇒ Object
8 9 10 |
# 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) ⇒ Object
8 9 10 |
# 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) ⇒ Object
12 13 14 15 |
# 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 |