Class: MuckEngine::Models::Matchers::IsPublicMatcher

Inherits:
MuckMatcherBase show all
Defined in:
lib/muck-engine/test/models/matchers/scope_is_public_matchers.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(scope, field = :is_public) ⇒ IsPublicMatcher

Returns a new instance of IsPublicMatcher.



17
18
19
20
# File 'lib/muck-engine/test/models/matchers/scope_is_public_matchers.rb', line 17

def initialize(scope, field = :is_public)
  @scope = scope
  @field = field
end

Instance Method Details

#descriptionObject



35
36
37
# File 'lib/muck-engine/test/models/matchers/scope_is_public_matchers.rb', line 35

def description
  "public items"
end

#failure_messageObject



31
32
33
# File 'lib/muck-engine/test/models/matchers/scope_is_public_matchers.rb', line 31

def failure_message
  "Expected #{factory_name} to scope by #{@scope} on #{@field} and only find public items. But the call failed"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
# File 'lib/muck-engine/test/models/matchers/scope_is_public_matchers.rb', line 22

def matches?(subject)
  @subject = subject
  @subject.class.delete_all
  public_item = Factory(factory_name, @field => true)
  not_public_item = Factory(factory_name, @field => false)
  @subject.class.send(@scope).include?(public_item) &&
    !@subject.class.send(@scope).include?(not_public_item)
end