Class: RSpec::Rails::ViewPathBuilder
- Inherits:
-
Object
- Object
- RSpec::Rails::ViewPathBuilder
- Defined in:
- lib/rspec/rails/view_path_builder.rb
Overview
Builds paths for view specs using a particular route set.
Instance Method Summary collapse
-
#initialize(route_set) ⇒ ViewPathBuilder
constructor
A new instance of ViewPathBuilder.
-
#path_for(path_params) ⇒ Object
Given a hash of parameters, build a view path, if possible.
Constructor Details
#initialize(route_set) ⇒ ViewPathBuilder
Returns a new instance of ViewPathBuilder.
5 6 7 |
# File 'lib/rspec/rails/view_path_builder.rb', line 5 def initialize(route_set) self.class.send(:include, route_set.url_helpers) end |
Instance Method Details
#path_for(path_params) ⇒ Object
Given a hash of parameters, build a view path, if possible. Returns nil if no path can be built from the given params.
22 23 24 25 26 |
# File 'lib/rspec/rails/view_path_builder.rb', line 22 def path_for(path_params) url_for(path_params.merge(only_path: true)) rescue => e e. end |