Coder Social home page Coder Social logo

mountebank-gem's Issues

Release 0.0.2

  • Support for behaviors
  • Support for response arrays

add_stub does not support arrays of responses

I would expect the following code to work:

headers = { 'Content-Type' => 'application/json' }
responses = [Mountebank::Stub::HttpResponse.create(@status_code, headers, response1),
                      Mountebank::Stub::HttpResponse.create(@status_code, headers, response1)]
MockServices.client.add_stub(responses, predicate)

However, this does not work - it has an error posting to imposters. From the log:

debug: [mb:2525] ::1:59432 => {"port":4545,"protocol":"http","name":"My Stubs","stubs":[{"predicates":[{"and":[{"matches":{"path":"\\/v1\\/app\\/mypath1$"}},{"equals":{"method":"GET"}}]}]},{"responses":[{"is":{"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{}]}"}}],"predicates":[{"and":[{"equals":{"path":"/v1/app/mypath2"}},{"equals":{"method":"GET"}}]}]}]}
warn: [mb:2525] error creating imposter: [{"code":"bad data","message":"'responses' must be a non-empty array","source":{"predicates":[{"and":[{"matches":{"path":"\\/v1\\/app\\/mypath1$"}},{"equals":{"method":"GET"}}]}]}}]

It looks like someone forked and fixed this in 2015 (https://github.com/brunchgroupe/mountebank-gem/tree/bug/imposter_add_stub_array) but never filed an issue or submitted a pull request.

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.