evilmartians / evil-client Goto Github PK
View Code? Open in Web Editor NEWHuman-friendly DSL for writing HTTP(s) clients in Ruby
License: Other
Human-friendly DSL for writing HTTP(s) clients in Ruby
License: Other
The problematic place is: f4e2858#diff-a76cfc1380d763d073577d9d3d19ef3bR64
Here we throw out any original exception and make it ValidationError
even if it is apparently not a such.
I have faced it several times while contributing to ebay_api or even bugs in the evil-client itself (e.g., with I18n error fixed in 89e3a8b) and it was always a pain to find the root cause of the problem.
So we need to distinguish usual exceptions (bugs) from real validation errors somehow. Have no idea how to do it at the moment though.
... for new DSL
Quoting a comment of @palkan :
What about adding some support for integration tests too? I mean something like that:
before { stub_operation(CatClient, "cats.fetch") }
# or
before { stub_operation(CatClient, /cats\..*/) }
# or with return value
before { stub_operation(CatClient, /.*/).and_return(double("Cat")) }
# or with constraints
before { stub_operation(CatClient, "cats.fetch").with(token: "valid") }
# etc
Now I'm testing evil-client integration the following way:
let(:candidates) do
double('candidates').tap do |stub|
allow(client).to receive(:candidates).and_return(stub)
end
end
it "works" do
expect(candidates).to receive(:create).with(
...
).and_return(double('response', id: 'checkr-123'))
# check some code that handles the response
end
... or limit ourselves with stabbing
Example:
client.users[1].get! \
headers: {
'If-Modified-Since' => Time.now - 3600
}
A client should return with nil
when a server responded without content. (For now it returns empty string).
Hi guys! First of all, it's awesome client!
During development I stucked with self-signed certificate problem.
Can't figure out how to use connection
writer with Faraday or HTTPClient, for example.
Supposing to use HTTPClient:
client = HTTPClient.new
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
But I can't figure out how to use it with Evil::Client descendant ๐คท
Any thoughts?
In the example
allow(client)
.to receive_request(:get)
.with { |req| req.path == '/foo/:id' }
.with { |req| req.body == { bar: :baz } }
.and_respond(200, foo: :qux }
RSpec warns about the second with
re-writes previous stub.
---
# config.yml
- name: "A"
code: 65
- name: "B"
code: 66
class Codepoint < Evil::Client::Model
extend Evil::Client::Dictionary["config.yml"]
option :name
option :code
end
Codepoint.all
# => `new': wrong number of arguments (given 1, expected 0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.