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

grasshopper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grasshopper

  • 1.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Grasshopper

A tiny mocking framework focused on the Arrage-Act-Assert test pattern. Grasshopper is heavily modeled after Mockito.

Examples

For more examples, see the unit tests

Mock

Mock is a person who listens carefully but never says anything. You can say anything to Mock, but you'll only get crickets back.

mock = Grasshopper::Mock.new
mock.hello                   #=> nil
mock.how_are_you?            #=> nil
Grasshopper::Mock.verify(mock).hello      # yes, someone did tell me hello.
Grasshopper::Mock.verify(mock).goodbye    # wait(AssertionFailed)! they left without saying goodbye!

Stub

Stub is a person who holds something for you and gives it to anyone who knows how to ask. You can ask Stub for anything, but you'll only get out what you put into it.

stub = Grasshopper::Stub.new
Grasshopper::Stub.when(stub.keys).then_return([:door_key, :mail_key])
Grasshopper::Stub.when(stub.money("gimmie")).then_return(5)
stub.keys                    #=> [:door_key, :mail_key]
stub.money("gimmie")         #=> 5
stub.monkey                  #=> nil

or you can use this shorter style if you prefer:

Grasshopper::Stub.like(:keys => [:door_key, :mail_key], :money => 5)
stub.keys                    #=> [:door_key, :mail_key]
stub.money("gimmie")         #=> 5
stub.monkey                  #=> nil

Naming

Grasshopper is named for a restaurant in Allston, MA that serves up all sorts of great mocks.

Copyright 2011-2021 Position Development, LLC.

Grasshopper is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Grasshopper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with Grasshopper. If not, see http://www.gnu.org/licenses/.

FAQs

Package last updated on 12 Jan 2021

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