Giter Site home page Giter Site logo

mockagne's Introduction

mockagne - Mocking Framework for Lua

Build Status

mockagne is a fully dynamic mocking framework that is designed to be a Lua variant of the famous Java framework mockito.

In a Nutshell

local mockagne = require("mockagne")
local mock = mockagne.getMock()
mockagne.when(mock.say(mockagne.any())).thenAnswer("Hello world")
-- ...
mock.ask("What's your name?")
mockagne.verify(mock.ask("What's your name?"))

Information for Users

Dependencies

Runtime Dependencies

mockagne is a single-file pure-Lua module with no other runtime dependencies than Lua 5.1 or later.

Test Dependencies

Dependency Purpose License
busted Unit testing framework MIT License

License

mockagne is Open Source, distributed under the terms of the MIT license.

Copyright (c) 2013 Punch Wolf Game Studios. Copyright (c) 2020 Exasol.

mockagne's People

Contributors

kaklakariada avatar redcatbear avatar vertti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mockagne's Issues

Mocking subsequent calls with identical parameters

Situation

I have tests where I need to mock subsequent calls to the same method of a mock with different results.
Unfortunately so far I always get the result defined in the first occurrence of

when(mock.do_something(parameter)).then(answer(10))
...
when(mock.do_something(parameter)).then(answer(20))

I am not sure if I am using the mock incorrectly or if that is not yet supported.
In the same context a resetMethodMocks() method would be nice.

Lua 5.3: Attempt to call a nil value (global 'unpack')

Situation

When trying to use mockagne with Lua 5.3, the following error is thrown.

mockagne.lua:145: attempt to call a nil value (global 'unpack')

Looking at the code unpack() is used a handful of times as global reference. In Lua 5.3 the unpack function was moved into table.

Steps to reproduce

  • Run existing tests on Lua 5.3

Proposed fix

Add the following for a backward-compatible fix:

local unpack = table.unpack or unpack

Update Rockspec with GitHub as source

Situation

Mockagne's source is hosted on GitHub. LuaRocks can create rock straight out of GitHub repos, given the correct configuration in the Rockspec.

Acceptance Criteria

  1. Rockspec updated with GitHub as source
  2. Package deployed successfully on LuaRocks.

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.