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

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

Instance Method Summary collapse

Constructor Details

#initialize(attr_name) ⇒ void

Parameters:

  • attr_name (String, Symbol)


17
18
19
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 17

def initialize(attr_name)
  @attr_name = attr_name
end

Instance Method Details

#descriptionString

Returns:

  • (String)


40
41
42
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 40

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

#failure_messageString

Returns:

  • (String)


47
48
49
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 47

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

#failure_message_when_negatedString

Returns:

  • (String)


54
55
56
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 54

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

#matches?(object) ⇒ Boolean

Parameters:

  • object (Object)

    Can be any object.

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_accessor.rb', line 28

def matches?(object)
  @object = object

  return false unless matches_attr_reader?
  return false unless matches_attr_writer?

  true
end