0.0
No commit activity in last 3 years
No release in over 3 years
RSpec::Endpoint provides the `endpoint` method as a helper to test HTTP requests. It parses and replaces the description with the informed params.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0
>= 3.0.0

Runtime

>= 3.0.0
 Project Readme

Rspec::Endpoint

Build Status

RSpec::Endpoint provides the endpoint method as a helper to test HTTP requests. It parses and replaces the description with the informed params.

Installation

Add this line to your application's Gemfile:

gem "rspec-endpoint"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rspec-endpoint

And require it as:

require "rspec/endpoint"

Example

RSpec.descripe UserApi do
  endpoint "GET /users/:user_id" do
    let(:user_id) { 10 }

    it { expect(path).to eq "/users/10" }
    it { expect(params).to eq user_id: 10 }
  end
end

rspec-endpoint will define a named subject make_request which calls the provided path using the http verb.

RSpec.descripe UserApi do
  endpoint "POST /users/:user_id" do
    let(:user_id) { 10 }

    it do
      # Named subject, same as:
      #   post path, params
      #
      # `params` here is `{ user_id: user_id }`
      make_request

      expect(response).to be_success
    end
  end
end