Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,12 @@ expect(a_request(:post, "www.example.com").

```ruby
stub = stub_request(:get, "www.example.com")

# ... make requests ...
expect(stub).to have_been_requested

expect(stub).to have_been_requested.twice
expect(stub).to have_been_requested.once.with(body: {"a" => [1, 2, 3]})
expect(stub).to have_been_requested.once.with(body: {"a" => [4, 5, 6]})
```

## Clearing stubs and request history
Expand Down
7 changes: 7 additions & 0 deletions lib/webmock/rspec/matchers/request_pattern_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ def at_most_times(times)
self
end

def with(options = {}, &block)
@request_pattern_with = [options, block]
self
end

def matches?(request_pattern)
@request_execution_verifier.request_pattern = request_pattern
@request_execution_verifier.request_pattern.with(@request_pattern_with[0], &@request_pattern_with[1]) if @request_pattern_with
@request_execution_verifier.matches?
end

def does_not_match?(request_pattern)
@request_execution_verifier.request_pattern = request_pattern
@request_execution_verifier.request_pattern.with(@request_pattern_with[0], &@request_pattern_with[1]) if @request_pattern_with
@request_execution_verifier.does_not_match?
end

Expand Down
Loading