lib/fun_with/testing/assertions/basics.rb
# Tries the given methods on both objects, reports on differing results
# Doesn't take a custom message.  Methods given must take zero arguments.
Tries the given methods on both objects, reports on differing results
Doesn't take a custom message.  Methods given must take zero arguments.
Tries the given methods on both objects reports on differing results Doesn ' t take a custom message . Methods given must take zero arguments .
def assert_equality_of_methods( expected, actual, *methods )
          failed = false
          results_msg = {}
          results_msg[:expected] = "The following methods were not equal: \nExpected: #{mu_pp(expected)}"
          results_msg[:actual]   = "\n--------------------\nActual: #{mu_pp(actual)}"
          for method in methods
            no_error_on_method = true
            responses = {}
            for obj, response_sym in [[expected, :expected], [actual, :actual]]
              responses[response_sym] = begin
                                          obj.send( method )
                                        rescue StandardError => e
                                          e
                                        end
              if responses[response_sym].is_a?( StandardError )
                failed = true
                no_error_on_method = false
                results_msg[response_sym] << "\n\t#{method}(): ERROR: #{responses[response_sym].class} #{responses[response_sym].message}"
              end
            end
            if responses[:expected] != responses[:actual] && no_error_on_method
              failed = true
              for response_sym in [:expected, :actual]
                results_msg[response_sym] << "\n\t#{method}(): #{responses[response_sym].inspect}"
              end
            end
          end
          assert !failed, results_msg[:expected] + results_msg[:actual]
        end
def assert_equality_of_methods ( expected , actual , * methods ) failed = false results_msg = { } results_msg [ :expected ] = "The following methods were not equal: \nExpected: #{mu_pp(expected)}" results_msg [ :actual ] = "\n--------------------\nActual: #{mu_pp(actual)}" for method in methods no_error_on_method = true responses = { } for obj , response_sym in [ [ expected , :expected ] , [ actual , :actual ] ] responses [ response_sym ] = begin obj . send ( method ) rescue StandardError => e e end if responses [ response_sym ] . is_a? ( StandardError ) failed = true no_error_on_method = false results_msg [ response_sym ] << "\n\t#{method}(): ERROR: #{responses[response_sym].class} #{responses[response_sym].message}" end end if responses [ :expected ] != responses [ :actual ] && no_error_on_method failed = true for response_sym in [ :expected , :actual ] results_msg [ response_sym ] << "\n\t#{method}(): #{responses[response_sym].inspect}" end end end assert ! failed , results_msg [ :expected ] + results_msg [ :actual ] end
Tries the given methods on both objects, reports on differing results
Doesn't take a custom message.
Tries the given methods on both objects reports on differing results Doesn ' t take a custom message .
expected
<not_specific>
actual
<not_specific>
methods
<not_specific>