Class: Shoulda::Matchers::ActionController::RouteMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActionController::RouteMatcher
- Defined in:
- lib/shoulda/matchers/action_controller/route_matcher.rb
Instance Attribute Summary collapse
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_when_negated ⇒ Object
- #in_context(context) ⇒ Object
-
#initialize(context, method, path, port: nil) ⇒ RouteMatcher
constructor
A new instance of RouteMatcher.
- #matches?(controller) ⇒ Boolean
- #to(*args) ⇒ Object
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_message ⇒ Object (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 end |
Instance Method Details
#description ⇒ Object
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_negated ⇒ Object
162 163 164 |
# File 'lib/shoulda/matchers/action_controller/route_matcher.rb', line 162 def "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
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 |