Sha256: e4f5f1c93c7aae3513fb5385e8cf5672e420df6261311c926202ae1a5bf42693
Contents?: true
Size: 1.29 KB
Versions: 6
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module EacRailsGemSupport module Rspec module MinitestSupport def assert_difference(code, message = nil, compare_method = :not_to, &block) before_value = assert_difference_call(code) block.call after_value = assert_difference_call(code) expect(after_value).send(compare_method, eq(before_value), message) end def assert_no_difference(code, message = nil, &block) assert_difference(code, message, :to, &block) end def assert_equal(expected_value, actual_value, message = nil) expect(actual_value).to eq(expected_value), message end def assert_not(expected_value, message = nil) expect(expected_value).to be_falsy, message end def assert_not_equal(expected_value, actual_value, message = nil) expect(actual_value).not_to eq(expected_value), message end def assert_raise(*expected_types, &block) expect(&block).to raise_error(*expected_types) end private def assert_difference_call(code) if code.is_a?(::Proc) code.call elsif code.is_a?(::String) eval(code) # rubocop:disable Security/Eval else raise "Unmapped type for \"#{code}\"" end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems