Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Mockingbird makes it easy to test code that relies on the Twitter Streaming API. It's a server with a simple script-like configuration DSL that makes it easy to describe the behaviors you want. Mockingbird can be used to simulate bad data, unexpected status codes, hard disconnects, etc. It's currently used heavily to test the flamingo Streaming API service.
Mockingbird uses eventmachine to run as an actual streaming HTTP server so it's a drop-in replacement for the server at stream.twitter.com. To test code that uses the Streaming API, connect to a running mockingbird server instead of stream.twitter.com. Most Twitter Streaming API clients, such as twitter-stream, allow you to easily change these host and port settings.
Since mockingbird is designed for testing, it includes a simple Mockingbird#setup and Mockingbird#teardown interface that makes it easy to configure and spawn a server for testing purposes during unit tests.
Mockingbird uses a simple script-like configuration API for telling a mockingbird server what you want it to do. Here's a simple example:
Mockingbird.setup(:port=>8080) do
send '{"foo":"bar"}'
wait 1
5.times do
send '{"foo2":"bar2"}'
end
pipe "some/file.txt", :wait=>1
close
end
Here's what this does in plain english:
Mockingbird assigns each conection an incrementing id. This means you can specify behavior over multiple connections with different connections doing different things. This is handy for testing reconnection code:
Mockingbird.setup(:port=>8080) do
on_connection(1) do
disconnect!
end
on_connection(2..5) do
wait(0.5)
close
end
on_connection('*') do
100.times do
send '{"foo":"bar"}'
end
close
end
end
Again, in plain english:
See the docs on Mockingbird::Script for all the available configuration options. Also, see the examples directory for more usage.
The basic pattern for using Mockingbird in your unit tests is to simply call Mockingbird#setup and Mockingbird#teardown at appropriate times. This will setup a mockingbird server in a separate process and then kill it when you're done. Make sure to always call Mockingbird#teardown. This is easy in test/unit if you're actually calling these methods in setup and teardown. If you need to setup and teardown a server in a test method, do the following:
def test_something
Mockingbird.setup(:port=>NNNN) do
# config here
end
# do tests
ensure
Mockingbird.teardown
end
FAQs
Unknown package
We found that mockingbird demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.