Module: GovukAbTesting::RspecAssertions

Included in:
RspecHelpers
Defined in:
lib/govuk_ab_testing/rspec_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/rspec_assertions.rb', line 7

def assert_contains_substring(string:, substring:, error_message:)
  expect(string).to include(substring), error_message
end

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



11
12
13
14
15
# File 'lib/govuk_ab_testing/rspec_assertions.rb', line 11

def assert_does_not_contain_substring(string:, substring:, error_message:)
  return if string.nil?

  expect(string).not_to include(substring), error_message
end

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



17
18
19
# File 'lib/govuk_ab_testing/rspec_assertions.rb', line 17

def assert_has_size(enumerable:, size:, error_message:)
  expect(enumerable.count).to eq(size), error_message
end

#assert_is_empty(enumerable:, error_message:) ⇒ Object



21
22
23
# File 'lib/govuk_ab_testing/rspec_assertions.rb', line 21

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

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



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

def assert_is_equal(expected:, actual:, error_message:)
  expect(actual).to eq(expected), error_message
end

#assert_not_blank(string:, error_message:) ⇒ Object



25
26
27
28
# File 'lib/govuk_ab_testing/rspec_assertions.rb', line 25

def assert_not_blank(string:, error_message:)
  expect(string).not_to be_nil, error_message
  expect(string.length).not_to eq(0), error_message
end