Module: GovukAbTesting::MinitestAssertions

Included in:
MinitestHelpers
Defined in:
lib/govuk_ab_testing/minitest_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_contains_substring(string:, substring:, error_message:) ⇒ Object



7
8
9
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 7

def assert_contains_substring(string:, substring:, error_message:)
  assert_match(/#{substring}/, string, error_message)
end

#assert_does_not_contain_substring(string:, substring:, error_message:) ⇒ Object



11
12
13
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 11

def assert_does_not_contain_substring(string:, substring:, error_message:)
  refute_match(/#{substring}/, string, error_message)
end

#assert_has_size(enumerable:, size:, error_message:) ⇒ Object



15
16
17
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 15

def assert_has_size(enumerable:, size:, error_message:)
  assert_equal(size, enumerable.count, error_message)
end

#assert_is_empty(enumerable:, error_message:) ⇒ Object



19
20
21
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 19

def assert_is_empty(enumerable:, error_message:)
  assert_has_size(enumerable: enumerable, size: 0, error_message: error_message)
end

#assert_is_equal(expected:, actual:, error_message:) ⇒ Object



3
4
5
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 3

def assert_is_equal(expected:, actual:, error_message:)
  assert_equal(expected, actual, error_message)
end

#assert_not_blank(string:, error_message:) ⇒ Object



23
24
25
26
# File 'lib/govuk_ab_testing/minitest_assertions.rb', line 23

def assert_not_blank(string:, error_message:)
  refute_nil(string, error_message)
  refute_equal(string.length, 0, error_message)
end