Class: Warp::ControllerMatchers::AssignMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/warp/controller_matchers/assign_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assign_key, controller) ⇒ AssignMatcher

Returns a new instance of AssignMatcher.



43
44
45
46
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 43

def initialize(assign_key, controller)
  @assign_key = assign_key
  @controller = controller
end

Instance Attribute Details

#assign_keyObject (readonly)

Returns the value of attribute assign_key.



41
42
43
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 41

def assign_key
  @assign_key
end

#controllerObject (readonly)

Returns the value of attribute controller.



41
42
43
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 41

def controller
  @controller
end

Instance Method Details

#descriptionObject



53
54
55
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 53

def description
  "assign @#{assign_key}"
end

#failure_messageObject



57
58
59
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 57

def failure_message
  "expected @#{assign_key} to be assigned"
end

#failure_message_when_negatedObject



61
62
63
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 61

def failure_message_when_negated
  "expected @#{assign_key} to not be assigned"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 48

def matches?(actual)
  @controller = actual if actual.is_a?(ActionController::Metal)
  check_assign
end