Module: ActionFigure::Testing::RSpec

Defined in:
lib/action_figure/testing/rspec.rb

Overview

RSpec custom matchers for ActionFigure response results.

Require in your spec_helper.rb to get be_Ok, be_Created, etc.:

require 'action_figure/testing/rspec'

RSpec.describe Users::Create do
  it "returns ok" do
    expect(Users::Create.call(params: ...)).to be_Ok
    expect(Users::Create.call(params: ...)).to have_action_json(status: "success")
  end
end

Constant Summary collapse

MATCHERS =
{
  Ok: :ok,
  Created: :created,
  Accepted: :accepted,
  NoContent: :no_content,
  UnprocessableContent: :unprocessable_content,
  NotFound: :not_found,
  Forbidden: :forbidden,
  Conflict: :conflict,
  PaymentRequired: :payment_required
}.freeze