fakeweb
fakeweb copied to clipboard
Ruby test helper for injecting fake responses to web requests
``` require 'fakeweb' FakeWeb.allow_net_connect = false reg = /http:\/\/a\.com\?a=1/ uri=URI("http://a.com?a=1") FakeWeb.register_uri(:get, reg, body: 'ok') Net::HTTP.get(uri) ``` results in a `FakeWeb::NetConnectNotAllowedError (Real HTTP connections are disabled. Unregistered request: GET http://a.com/?a=1)` But...
Right now, if I want to verify that I'm POST'ing the right data, I need to do something like this: ``` FakeWeb.register_uri(:post, my_url, body: 'i-dont-care-about-the-response-only-the-request') do_something_that_hits_my_url request_data = CGI.parse FakeWeb.last_request.body_stream.instance_variable_get('@stream').string...
``` ┌──────────────────────────────────────────────────────────────────────────────┐ │ Run tests for ruby2.5 from debian/ruby-tests.rb │ └──────────────────────────────────────────────────────────────────────────────┘ RUBYLIB=//ruby-fakeweb-1.3.0+git20170806+dfsg1/debian/ruby-fakeweb/usr/lib/ruby/vendor_ruby:. GEM_PATH=debian/ruby-fakeweb/usr/share/rubygems-integration/all:/var/lib/gems/2.5.0:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0:/usr/share/rubygems-integration/2.5.0:/usr/share/rubygems-integration/all ruby2.5 debian/ruby-tests.rb Loaded suite debian/ruby-tests Started ...................................................F =============================================================================== Failure: test_real_https_request(TestFakeWeb): not all expectations were satisfied unsatisfied expectations:...
Hi @chrisk Thanks for maintaining this gem. I added the Ruby latest version 2.6 to CI based on below pull-request. https://github.com/chrisk/fakeweb/pull/63 Do you like to start Travis CI on this...
The last version `1.3.0` was released **in year 2010**, 6 years ago! People needed to pull down changes which were made since that. Please please please bump up and release...
I installed fakeweb (1.3.0) in Ruby 2.4.1 and Rails 5.1.4 and when tried to use it I started to get a this error. Failure/Error: Net::HTTP.get(url) NoMethodError: undefined method ` 'https://github.com/chrisk/fakeweb.git'...
This PR changes the build badges to SVG for sharper readability ✨
All added Ruby versions tests pass at https://travis-ci.org/nicolasleger/fakeweb/builds/340300926
I needed to unregister URIs in one project that I'm using fakeweb and I was unable find this feature, so I implemented it for you.
## Problem Ruby 2.0 added a keep_alive_timeout variable to Net::HTTP for persistent. If keep_alive_timeout seconds has passed between requests, then Net::HTTP will close the socket and call connect. However, fakeweb...