Sha256: c7db80e7b5197ebd09a6c9c34ab221d9a171f79afab0473016d525b2be7673b9
Contents?: true
Size: 1.03 KB
Versions: 17
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module ConvenientService module RSpec module Matchers module Custom ## # TODO: Specs. # class HaveAttrWriter def initialize(attr_name) @attr_name = attr_name end def matches?(object) @object = object ## # IMPORTANT: A copy is created in order to be thread safe. # copy = object.dup copy.public_send("#{attr_name}=", :custom_value) copy.instance_variable_get("@#{attr_name}") == :custom_value end def description "have attr writer `#{attr_name}`" end def failure_message "expected `#{object.class}` to have attr writer `#{attr_name}`" end def failure_message_when_negated "expected `#{object.class}` NOT to have attr writer `#{attr_name}`" end private attr_reader :object, :attr_name end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems