Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAttrAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb

Overview

TODO: Specs.

Instance Method Summary collapse

Constructor Details

#initialize(attr_name) ⇒ HaveAttrAccessor

Returns a new instance of HaveAttrAccessor.



11
12
13
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 11

def initialize(attr_name)
  @attr_name = attr_name
end

Instance Method Details

#descriptionObject



24
25
26
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 24

def description
  "have attr accessor `#{attr_name}`"
end

#failure_messageObject



28
29
30
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 28

def failure_message
  "expected `#{object.class}` to have attr accessor `#{attr_name}`"
end

#failure_message_when_negatedObject



32
33
34
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 32

def failure_message_when_negated
  "expected `#{object.class}` NOT to have attr accessor `#{attr_name}`"
end

#matches?(object) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 15

def matches?(object)
  @object = object

  Classes::HaveAttrReader.new(attr_name).matches?(object)
  Classes::HaveAttrWriter.new(attr_name).matches?(object)

  true
end