module Assert::Macros::Methods::ClassMethods
Public Instance Methods
_methods_macro_class_methods()
click to toggle source
# File lib/assert/macros/methods.rb, line 168 def _methods_macro_class_methods @_methods_macro_class_methods ||= [] end
_methods_macro_instance_methods()
click to toggle source
# File lib/assert/macros/methods.rb, line 160 def _methods_macro_instance_methods @_methods_macro_instance_methods ||= [] end
_methods_macro_not_class_methods()
click to toggle source
# File lib/assert/macros/methods.rb, line 172 def _methods_macro_not_class_methods @_methods_macro_not_class_methods ||= [] end
_methods_macro_not_instance_methods()
click to toggle source
# File lib/assert/macros/methods.rb, line 164 def _methods_macro_not_instance_methods @_methods_macro_not_instance_methods ||= [] end
_methods_macro_test(called_from)
click to toggle source
private
# File lib/assert/macros/methods.rb, line 112 def _methods_macro_test(called_from) @_methods_macro_test ||= test "should respond to methods", called_from do self .class ._methods_macro_instance_methods .each do |(method, called_from)| msg = "#{subject.class.name} does not have "\ "instance method ##{method}" with_backtrace([called_from]) do assert_that(subject).responds_to(method, msg) end end self .class ._methods_macro_class_methods .each do |(method, called_from)| msg = "#{subject.class.name} does not have class method ##{method}" with_backtrace([called_from]) do assert_that(subject.class).responds_to(method, msg) end end self .class ._methods_macro_not_instance_methods .each do |(method, called_from)| msg = "#{subject.class.name} has instance method ##{method}" with_backtrace([called_from]) do assert_that(subject).does_not_respond_to(method, msg) end end self .class ._methods_macro_not_class_methods .each do |(method, called_from)| msg = "#{subject.class.name} has class method ##{method}" with_backtrace([called_from]) do assert_that(subject.class).does_not_respond_to(method, msg) end end end end
have_accessor(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 94 def have_accessor(*methods) called = methods.last.is_a?(Array) ? methods.pop : caller_locations accessor_meths = methods.map{ |m| [m, "#{m}="] }.flatten accessor_meths << called have_instance_methods(*accessor_meths) end
Also aliased as: have_accessors
have_class_method(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 40 def have_class_method(*methods) called_from = (methods.last.is_a?(Array) ? methods.pop : caller_locations).first Assert::Macro.new do methods.each{ |m| _methods_macro_class_methods << [m, called_from] } _methods_macro_test called_from end end
have_instance_method(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 12 def have_instance_method(*methods) called_from = (methods.last.is_a?(Array) ? methods.pop : caller_locations).first Assert::Macro.new do methods.each do |m| _methods_macro_instance_methods << [m, called_from] end _methods_macro_test called_from end end
have_reader(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 66 def have_reader(*methods) methods << caller_locations unless methods.last.is_a?(Array) have_instance_methods(*methods) end
Also aliased as: have_readers
have_writer(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 78 def have_writer(*methods) called = methods.last.is_a?(Array) ? methods.pop : caller_locations writer_meths = methods.map{ |m| "#{m}=" } writer_meths << called have_instance_methods(*writer_meths) end
Also aliased as: have_writers
not_have_accessor(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 102 def not_have_accessor(*methods) called = methods.last.is_a?(Array) ? methods.pop : caller_locations accessor_meths = methods.map{ |m| [m, "#{m}="] }.flatten accessor_meths << called not_have_instance_methods(*accessor_meths) end
Also aliased as: not_have_accessors
not_have_class_method(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 52 def not_have_class_method(*methods) called_from = (methods.last.is_a?(Array) ? methods.pop : caller_locations).first Assert::Macro.new do methods.each do |m| _methods_macro_not_class_methods << [m, called_from] end _methods_macro_test called_from end end
not_have_instance_method(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 26 def not_have_instance_method(*methods) called_from = (methods.last.is_a?(Array) ? methods.pop : caller_locations).first Assert::Macro.new do methods.each do |m| _methods_macro_not_instance_methods << [m, called_from] end _methods_macro_test called_from end end
not_have_reader(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 72 def not_have_reader(*methods) methods << caller_locations unless methods.last.is_a?(Array) not_have_instance_methods(*methods) end
Also aliased as: not_have_readers
not_have_writer(*methods)
click to toggle source
# File lib/assert/macros/methods.rb, line 86 def not_have_writer(*methods) called = methods.last.is_a?(Array) ? methods.pop : caller_locations writer_meths = methods.map{ |m| "#{m}=" } writer_meths << called not_have_instance_methods(*writer_meths) end
Also aliased as: not_have_writers