Skip to content

What is DuckRails?

Lazarus Lazaridis edited this page Nov 18, 2017 · 7 revisions

DuckRails is an open source development tool built using the Ruby on Rails framework.

The purpose of the tool is to allow developers to easily mock API endpoints outside their applications.

Do I need the tool?

If you deal with API endpoints and you need to mock some of them for any reason, yes.

I don’t know ruby

Knowing ruby is not required. It would just help you define ruby dynamic mocks easier (embedded ruby). No worries, you can still define dynamic responses by selecting Javascript as the mock’s body type.

What are dynamic mocks?

Instead of defining a mock to always respond with some static content, you can also configure it to dynamically resolve the content to serve. For example, you can access the original request’s parameters and headers and decide how you could respond. You can see how to create dynamic mocks with Embedded Ruby here and with Javascript here.

Why would I need to mock API endpoints that I want to consume?

Some reasons:

  • They might be unavailable
  • You need functionality that hasn’t been implemented yet
  • You can’t access them in the development environment

Can you give me a use case?

Suppose you want to develop a new feature in your web application but the backend API is not yet ready to serve the feature. You can mock the new endpoints and set your application to consume DuckRails endpoints instead of the real ones.