How To Install ruby-webmock on Ubuntu 18.04

In this tutorial we learn how to install ruby-webmock on Ubuntu 18.04. ruby-webmock is library for stubbing HTTP requests in Ruby

Introduction

In this tutorial we learn how to install ruby-webmock on Ubuntu 18.04.

What is ruby-webmock

ruby-webmock is:

WebMock allows stubbing HTTP requests and setting expectations on HTTP requests.

Features

  • Stubbing HTTP requests at low http client lib level (no need to change tests when you change HTTP library).
  • Setting and verifying expectations on HTTP requests.
  • Matching requests based on method, URI, headers and body.
  • Smart matching of the same URIs in different representations (also encoded and non encoded forms).
  • Smart matching of the same headers in different representations.

There are three methods to install ruby-webmock on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install ruby-webmock Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install ruby-webmock using apt-get by running the following command:

sudo apt-get -y install ruby-webmock

Install ruby-webmock Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install ruby-webmock using apt by running the following command:

sudo apt -y install ruby-webmock

Install ruby-webmock Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install ruby-webmock using aptitude by running the following command:

sudo aptitude -y install ruby-webmock

How To Uninstall ruby-webmock on Ubuntu 18.04

To uninstall only the ruby-webmock package we can use the following command:

sudo apt-get remove ruby-webmock

Uninstall ruby-webmock And Its Dependencies

To uninstall ruby-webmock and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove ruby-webmock

Remove ruby-webmock Configurations and Data

To remove ruby-webmock configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge ruby-webmock

Remove ruby-webmock configuration, data, and all of its dependencies

We can use the following command to remove ruby-webmock configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge ruby-webmock

References

Summary

In this tutorial we learn how to install ruby-webmock package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.