Method: Expected::Matchers::HaveAttrAccessorMatcher#initialize

Defined in:
lib/expected/matchers/have_attr_accessor.rb

#initialize(attribute) ⇒ HaveAttrAccessorMatcher

Returns a new instance of HaveAttrAccessorMatcher.

Parameters:

  • attribute (String, Symbol)

    The attribute the #subject is expected to have an attr_accessor for



27
28
29
30
31
32
33
34
# File 'lib/expected/matchers/have_attr_accessor.rb', line 27

def initialize(attribute)
  unless attribute.is_a?(String) || attribute.is_a?(Symbol)
    raise 'HaveAttrAccessorMatcher attribute must be a String or Symbol'
  end
  @attribute = attribute.to_sym
  @has_attr_reader = HaveAttrReaderMatcher.new(attribute)
  @has_attr_writer = HaveAttrWriterMatcher.new(attribute)
end