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

Methods inherited from Matcher

#description_of, #failure_message_for_should, #failure_message_for_should_not, #values_match?

Constructor Details

#initialize(assign_key, controller) ⇒ AssignMatcher

Returns a new instance of AssignMatcher.



9
10
11
12
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 9

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.



6
7
8
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6

def assign_key
  @assign_key
end

#assign_withObject (readonly)

Returns the value of attribute assign_with.



6
7
8
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6

def assign_with
  @assign_with
end

#assign_with_aObject (readonly)

Returns the value of attribute assign_with_a.



6
7
8
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6

def assign_with_a
  @assign_with_a
end

#assign_with_a_newObject (readonly)

Returns the value of attribute assign_with_a_new.



6
7
8
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 6

def assign_with_a_new
  @assign_with_a_new
end

#controllerObject (readonly)

Returns the value of attribute controller.



7
8
9
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7

def controller
  @controller
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7

def description
  @description
end

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



7
8
9
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7

def failure_message
  @failure_message
end

#failure_message_when_negatedObject (readonly)

Returns the value of attribute failure_message_when_negated.



7
8
9
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 7

def failure_message_when_negated
  @failure_message_when_negated
end

Instance Method Details

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 29

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

  if multiple_assertions?
    raise "Only one of .with, .with_a, and .with_a_new can be used with the assigns matcher."
  end

  return check_assign_with if assign_with
  return check_assign_with_a if assign_with_a
  return check_assign_with_a_new if assign_with_a_new
  return check_assign
end

#with(assign_eq) ⇒ Object



14
15
16
17
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 14

def with(assign_eq)
  @assign_with = assign_eq
  self
end

#with_a(assign_class) ⇒ Object



19
20
21
22
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 19

def with_a(assign_class)
  @assign_with_a = assign_class
  self
end

#with_a_new(assign_class) ⇒ Object



24
25
26
27
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 24

def with_a_new(assign_class)
  @assign_with_a_new = assign_class
  self
end