Class: ConvenientService::RSpec::Matchers::Classes::Export

Inherits:
Object
  • Object
show all
Includes:
Support::DependencyContainer::Import
Defined in:
lib/convenient_service/rspec/matchers/classes/export.rb

Instance Method Summary collapse

Methods included from Support::DependencyContainer::Import

import

Constructor Details

#initialize(slug, scope: constants.DEFAULT_SCOPE) ⇒ void

Parameters:

  • slug (Symbol, String)
  • scope (Symbol) (defaults to: constants.DEFAULT_SCOPE)


24
25
26
27
# File 'lib/convenient_service/rspec/matchers/classes/export.rb', line 24

def initialize(slug, scope: constants.DEFAULT_SCOPE)
  @slug = slug
  @scope = scope
end

Instance Method Details

#descriptionString

Returns:

  • (String)


46
47
48
# File 'lib/convenient_service/rspec/matchers/classes/export.rb', line 46

def description
  "export `#{slug}` with scope `#{scope}`"
end

#failure_messageString

Returns:

  • (String)


53
54
55
# File 'lib/convenient_service/rspec/matchers/classes/export.rb', line 53

def failure_message
  "expected `#{container}` to export `#{slug}` with scope `#{scope}`"
end

#failure_message_when_negatedString

Returns:

  • (String)


60
61
62
# File 'lib/convenient_service/rspec/matchers/classes/export.rb', line 60

def failure_message_when_negated
  "expected `#{container}` NOT to export `#{slug}` with scope `#{scope}`"
end

#matches?(container) ⇒ Boolean

Parameters:

  • container (Module)

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
# File 'lib/convenient_service/rspec/matchers/classes/export.rb', line 33

def matches?(container)
  @container = container

  commands.AssertValidContainer.call(container: container)

  commands.AssertValidScope.call(scope: scope)

  Utils.to_bool(container.exported_methods.find_by(slug: slug, scope: scope))
end