Class: MuckEngine::Models::Matchers::OrdinalMatcher

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(scope, field) ⇒ OrdinalMatcher

Returns a new instance of OrdinalMatcher.



22
23
24
25
# File 'lib/muck-engine/test/models/matchers/scope_ordinal_matchers.rb', line 22

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

Instance Method Details

#descriptionObject



39
40
41
# File 'lib/muck-engine/test/models/matchers/scope_ordinal_matchers.rb', line 39

def description
  "sort by ordinal"
end

#failure_messageObject



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

def failure_message
  "Expected #{factory_name} to have scope #{@scope} and order by #{@field}"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/muck-engine/test/models/matchers/scope_ordinal_matchers.rb', line 27

def matches?(subject)
  @subject = subject
  @subject.class.delete_all
  @first = Factory(factory_name, @field => 1)
  @second = Factory(factory_name, @field => 2)
  @first == @subject.class.send(@scope)[0] && @second == @subject.class.send(@scope)[1]
end