Class: Warp::ControllerMatchers::AssignWithAMatcher

Inherits:
AssignMatcher show all
Defined in:
lib/warp/controller_matchers/assign_matcher.rb

Instance Attribute Summary collapse

Attributes inherited from AssignMatcher

#assign_key, #controller

Instance Method Summary collapse

Methods inherited from AssignMatcher

#matches?

Constructor Details

#initialize(controller, assign_key, assign_with_a) ⇒ AssignWithAMatcher

Returns a new instance of AssignWithAMatcher.



113
114
115
116
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 113

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

Instance Attribute Details

#assign_with_aObject (readonly)

Returns the value of attribute assign_with_a.



111
112
113
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 111

def assign_with_a
  @assign_with_a
end

Instance Method Details

#descriptionObject



118
119
120
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 118

def description
  "assign @#{assign_key} with an instance of #{assign_with_a.name}"
end

#failure_messageObject



122
123
124
125
126
127
128
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 122

def failure_message
  if assign_value.nil?
    "expected @#{assign_key} to be assigned with an instance of #{assign_with_a.name} but was not assigned"
  else
    "expected @#{assign_key} to be assigned with an instance of #{assign_with_a.name} but was assigned with an instance of #{assign_value.class.name}"
  end
end

#failure_message_when_negatedObject



130
131
132
# File 'lib/warp/controller_matchers/assign_matcher.rb', line 130

def failure_message_when_negated
  "expected @#{assign_key} to not be assigned with an instance of #{assign_with_a.name}"
end