Class: Remarkable::Controller::Matchers::Route

Inherits:
Matcher::Base show all
Defined in:
lib/remarkable/controller/macros/route_matcher.rb

Instance Method Summary collapse

Methods inherited from Matcher::Base

#failure_message, #negative, #negative_failure_message, #spec

Methods included from Matcher::DSL

included

Constructor Details

#initialize(method, path, options) ⇒ Route

Returns a new instance of Route.



5
6
7
8
9
# File 'lib/remarkable/controller/macros/route_matcher.rb', line 5

def initialize(method, path, options)
  @method  = method
  @path    = path
  @options = options
end

Instance Method Details

#descriptionObject



35
36
37
# File 'lib/remarkable/controller/macros/route_matcher.rb', line 35

def description
  expectation
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/remarkable/controller/macros/route_matcher.rb', line 11

def matches?(subject)
  @subject = subject

  initialize_with_spec!

  unless @options[:controller]
    @options[:controller] = @controller.class.name.gsub(/Controller$/, '').tableize
  end
  @options[:controller] = @options[:controller].to_s
  @options[:action] = @options[:action].to_s

  @populated_path = @path.dup
  @options.each do |key, value|
    @options[key] = value.to_param if value.respond_to?(:to_param)
    @populated_path.gsub!(key.inspect, value.to_s)
  end

  ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
  assert_matcher do
    map_to_path? &&
    generate_params?
  end
end