🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

trailblazer-test

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trailblazer-test

bundlerRubygems
Version
1.0.0
Version published
Maintainers
1
Created
Source

Trailblazer::Test

Assertions and helpers for operation unit tests.

The comprehensive docs are here.

Read our introducing blog post for a better overview.

Installation

Add the following line to your project's Gemfile.

gem "trailblazer-test", ">= 1.0.0", "< 2.0.0"

Overview

This gem adds the following assertions and helpers:

  • #assert_pass to test an operation terminating with success.
  • #assert_fail to assert validation errors and the like.
  • #mock_step helping the replace steps with stubs.

Example

An example test case checking if an operation passed and created a model could look as follows.

# test/operation/memo_test.rb

require "test_helper"

class MemoOperationTest < Minitest::Spec
  Trailblazer::Test.module!(self) # install our helpers.

  it "passes with valid input" do
    # ...
    assert_pass Memo::Operation::Create, input,
      content:    "Stock up beer",
      persisted?: true,
      id:         ->(asserted:, **) { asserted.id > 0 }
  end
end

FAQs

Package last updated on 10 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts