Module: MiniTest::Assertions

Defined in:
lib/feldtruby/minitest_extensions.rb

Instance Method Summary collapse

Instance Method Details

#assert_falsey(value, msg = nil) ⇒ Object



14
15
16
# File 'lib/feldtruby/minitest_extensions.rb', line 14

def assert_falsey(value, msg = nil)
  assert(value.!, msg || "#{value} is not falsey (it is #{value})")
end

#assert_similar_proportions(values, expectedPValue = 0.01, msg = nil) ⇒ Object

Ensure that that are (statistically) the same number of each type of value in an array.



9
10
11
12
# File 'lib/feldtruby/minitest_extensions.rb', line 9

def assert_similar_proportions(values, expectedPValue = 0.01, msg = nil)
  pvalue = FeldtRuby.chi_squared_test(values)
  assert(pvalue > expectedPValue, msg || "Proportions differ! p-value is #{pvalue} (<0.05), counts: #{values.counts.inspect}")
end

#assert_truthy(value, msg = nil) ⇒ Object



18
19
20
# File 'lib/feldtruby/minitest_extensions.rb', line 18

def assert_truthy(value, msg = nil)
  assert(value, msg || "#{value} is not truthy (it is #{value})")
end