New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mocksocket

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocksocket

  • 0.2.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

mocksocket

tiny class providing an IO/TCPSocket mock, full duplex and everything. mainly useful for testing TCPSocket applications.

require 'mocksocket' client, server = MockSocket.pipe #=> [M, M] client.puts "hello, I'm a client!" server.gets #=> "hello, I'm a client!\n" server.puts "welcome, client." client.gets #=> "welcome, client.\n"

it uses Timeout, so instead of stalled tests, you get some timeout exception, if you're trying to read from an empty buffer.

methods implemented: #puts, #print, #gets, #eof? and the ever-handy #empty?

as well there's tiny test extensions for test/unit:

require 'mocksocket/test'

module Test::Unit::Assertions include MockSocket::Assertions end

def setup @c, @s = MockSocket.pipe end

def test_empty_buffer assert_empty_buffer @c end

.. and bacon:

require 'mocksocket/bacon'

describe "awesome" do before { @c, @s = MockSocket.pipe } end

should "be empty" do @c.should.be empty_buffer end

that's about it. (c) 2009 harry vangberg and released under the MIT license. enjoy.

FAQs

Package last updated on 11 Dec 2009

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc