Skip to content

Instantly share code, notes, and snippets.

@danhodge
Last active February 25, 2021 22:32
Show Gist options
  • Save danhodge/f70887ab609883e8edefb9de124ad646 to your computer and use it in GitHub Desktop.
Save danhodge/f70887ab609883e8edefb9de124ad646 to your computer and use it in GitHub Desktop.
# Excon exposes defaults for injecting configuration parameters
Excon.defaults[:mock] = true
Excon.defaults.delete(:mock)
# Excon stubbing
# first parameter - Hash of expected request attributes (all are optional)
# second parameter - Hash of response attributes
# if second parameter is omitted, a block can be provided a Proc object
Excon.stub({ method: :post, path: exp_path, headers: exp_headers, query: exp_query, body: exp_body }, { status: 200 })
# Or, just use webmock directly
stub_request(:post, url).with(body: "", headers: {}).to_return(status: 200, body: "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment