Sha256: 80dd97b8b47b599bc817a9ff692695940aa4e25c87a419362bd16c79f473e0a9
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module ConvenientService module RSpec module PrimitiveMatchers module Classes ## # 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
6 entries across 6 versions & 1 rubygems