Coder Social home page Coder Social logo

mock_java's Introduction

MockJava - Mocking java classes in Ruby World!

Essential Information

Mock java is not a real mock, but a lib that creates a ruby class that extends java classes.

Since it creates a ruby class, you can use rspec to change the behaviour class since it's a real Ruby class!

I created this since I don't like the idea of using rspec using tools from java classes to mock like Mockito! So if you have the same will, this might be your tool!

Usage

First include the module in your spec_helper file:

RSpec.configure do |config|
  config.include MockJava
end

after importing your java file with:

java_import com.package.ExampleJavaClass

To mock this example class you mock with this command:

mock = mock_java ExampleJavaClass

If you need you need to pass arguments to your constructors use this:

mock = mock_java ExampleJavaClass, 'param1', 'param2'

If you already have an object you can mock with this:

example = ExampleJavaClass.new
mock = mock_java example

Contributting to MockJava

  • For, fix, then send me a pull request.

mock_java's People

Contributors

fredericobenevides avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.