Ruby webmock: Difference between revisions
From wikinotes
(Created page with "An HTTP request mocking library. = Documentation = <blockquote> {| class="wikitable" |- | github || https://github.com/bblimke/webmock |- |} </blockquote><!-- Documentation -...") |
|||
Line 13: | Line 13: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="ruby"> | <syntaxhighlight lang="ruby"> | ||
stub_request(:any, "www.example.com") | stub_request(:any, "www.example.com") # get, patch, post, ... | ||
stub_request(:get, /foo./) # regex match request | |||
stub_request(:get, lambda { |request| request.body == "abc" }) # | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Example --> | </blockquote><!-- Example --> |
Latest revision as of 18:19, 8 September 2021
An HTTP request mocking library.
Documentation
github https://github.com/bblimke/webmock
Example
stub_request(:any, "www.example.com") # get, patch, post, ... stub_request(:get, /foo./) # regex match request stub_request(:get, lambda { |request| request.body == "abc" }) #