Class: MuckEngine::Models::Matchers::CreatedByMatcher

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(scope, field) ⇒ CreatedByMatcher

Returns a new instance of CreatedByMatcher.



37
38
39
40
# File 'lib/muck-engine/test/models/matchers/scope_creator_matchers.rb', line 37

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

Instance Method Details

#descriptionObject



57
58
59
# File 'lib/muck-engine/test/models/matchers/scope_creator_matchers.rb', line 57

def description
  "scope created_by"
end

#failure_messageObject



53
54
55
# File 'lib/muck-engine/test/models/matchers/scope_creator_matchers.rb', line 53

def failure_message
  "Expected #{factory_name} to have scope created_by and to be able to successfully find #{@subject}'s creator"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
51
# File 'lib/muck-engine/test/models/matchers/scope_creator_matchers.rb', line 42

def matches?(subject)
  @subject = subject
  @subject.class.delete_all
  @user = Factory(:user)
  @user1 = Factory(:user)
  @item = Factory(factory_name, @field => @user)
  @item1 = Factory(factory_name, @field => @user1)
  items = @subject.class.send(@scope, @user)
  items.include?(@item) && !items.include?(@item1)
end