Class: WebMock::WebMockMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/webmock/rspec/matchers/webmock_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(method, uri) ⇒ WebMockMatcher

Returns a new instance of WebMockMatcher.



4
5
6
7
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 4

def initialize(method, uri)
  @request_execution_verifier = RequestExecutionVerifier.new
  @request_execution_verifier.request_pattern = RequestPattern.new(method, uri)
end

Instance Method Details

#at_least_onceObject



19
20
21
22
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 19

def at_least_once
  @request_execution_verifier.at_least_times_executed = 1
  self
end

#at_least_times(times) ⇒ Object



29
30
31
32
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 29

def at_least_times(times)
  @request_execution_verifier.at_least_times_executed = times
  self
end

#at_least_twiceObject



24
25
26
27
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 24

def at_least_twice
  @request_execution_verifier.at_least_times_executed = 2
  self
end

#descriptionObject



60
61
62
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 60

def description
  @request_execution_verifier.description
end

#does_not_match?(webmock) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 48

def does_not_match?(webmock)
  @request_execution_verifier.does_not_match?
end

#failure_messageObject



52
53
54
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 52

def failure_message
  @request_execution_verifier.failure_message
end

#failure_message_when_negatedObject Also known as: negative_failure_message



56
57
58
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 56

def failure_message_when_negated
  @request_execution_verifier.failure_message_when_negated
end

#matches?(webmock) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 44

def matches?(webmock)
  @request_execution_verifier.matches?
end

#onceObject



9
10
11
12
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 9

def once
  @request_execution_verifier.expected_times_executed = 1
  self
end

#times(times) ⇒ Object



39
40
41
42
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 39

def times(times)
  @request_execution_verifier.expected_times_executed = times.to_i
  self
end

#twiceObject



14
15
16
17
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 14

def twice
  @request_execution_verifier.expected_times_executed = 2
  self
end

#with(options = {}, &block) ⇒ Object



34
35
36
37
# File 'lib/webmock/rspec/matchers/webmock_matcher.rb', line 34

def with(options = {}, &block)
  @request_execution_verifier.request_pattern.with(options, &block)
  self
end