Class: Dbtap::SetEq

Inherits:
Tester show all
Defined in:
lib/dbtap/testers/set_eq.rb

Overview

Tests to see if two sets of results are equal

Sets is a bit of a misnomer in that if a query returns duplicate rows, those rows are NOT deduplicated.

The order in which either query returns the results is ignored when testing for equality.

Instance Attribute Summary collapse

Attributes inherited from Tester

#name

Instance Method Summary collapse

Methods inherited from Tester

#is_ok?

Constructor Details

#initialize(actual, expected, name = nil) ⇒ SetEq

actual - The query being tested expected - The set of results expected. Should be another query. name - (optional) the name of the test



18
19
20
21
22
# File 'lib/dbtap/testers/set_eq.rb', line 18

def initialize(actual, expected, name = nil)
  @name = name
  @actual = actual
  @expected = expected
end

Instance Attribute Details

#actualObject (readonly)

Returns the value of attribute actual.



13
14
15
# File 'lib/dbtap/testers/set_eq.rb', line 13

def actual
  @actual
end

Instance Method Details

#errorsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dbtap/testers/set_eq.rb', line 28

def errors
  drop_csv
  output = []
  unless missing.empty?
    output << "Missing #{missing.count}/#{expected_count} Records:"
    output << '  ' + missing.first.inspect
  end

  unless extras.empty?
    output << "Extra #{extras.count} over #{expected_count} Records:"
    output << '  ' + extras.first.inspect
  end
end

#ok?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dbtap/testers/set_eq.rb', line 24

def ok?
  missing.empty? && extras.empty?
end