Class: Shoulda::Matchers::ActionController::RouteMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/action_controller/route_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, method, path, port: nil) ⇒ RouteMatcher

Returns a new instance of RouteMatcher.



133
134
135
136
137
138
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 133

def initialize(context, method, path, port: nil)
  @context = context
  @method = method
  @path = add_port_to_path(normalize_path(path), port)
  @params = {}
end

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



140
141
142
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 140

def failure_message
  @failure_message
end

Instance Method Details

#descriptionObject



158
159
160
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 158

def description
  "route #{method.to_s.upcase} #{path} to/from #{params.inspect}"
end

#failure_message_when_negatedObject



162
163
164
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 162

def failure_message_when_negated
  "Didn't expect to #{description}"
end

#in_context(context) ⇒ Object



147
148
149
150
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 147

def in_context(context)
  @context = context
  self
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


152
153
154
155
156
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 152

def matches?(controller)
  guess_controller_if_necessary(controller)

  route_recognized?
end

#to(*args) ⇒ Object



142
143
144
145
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 142

def to(*args)
  @params = RouteParams.new(args).normalize
  self
end