Class: FakeWebMatcher::RequestMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_web_matcher/request_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RequestMatcher

Create a new matcher.



31
32
33
# File 'lib/fake_web_matcher/request_matcher.rb', line 31

def initialize(*args)
  @method, @url = args_split(*args)
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



24
25
26
# File 'lib/fake_web_matcher/request_matcher.rb', line 24

def method
  @method
end

#urlObject (readonly)

Returns the value of attribute url.



24
25
26
# File 'lib/fake_web_matcher/request_matcher.rb', line 24

def url
  @url
end

Instance Method Details

#failure_messageString

Failure message if the URI should have been requested.



52
53
54
# File 'lib/fake_web_matcher/request_matcher.rb', line 52

def failure_message
  regex?(@url) ? regex_failure_message : url_failure_message
end

#matches?(fakeweb) ⇒ Boolean

Indication of whether there's a match on the URI from given requests.



41
42
43
44
45
46
# File 'lib/fake_web_matcher/request_matcher.rb', line 41

def matches?(fakeweb)
  !FakeWeb::Registry.instance.requests.detect { |req|
    method, url = args_split(*req)
    match_method(method) && match_url(url)
  }.nil?
end

#negative_failure_messageString

Failure message if the URI should not have been requested.



60
61
62
# File 'lib/fake_web_matcher/request_matcher.rb', line 60

def negative_failure_message
  regex?(@url) ? regex_negative_failure_message : url_negative_failure_message
end