Sha256: d18943c335a1e6ac40cd45f24d1d35782d3fce7f1d2cfb7c5aff98ed73ca0e5c

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

module Logux
  module Test
    module Helpers
      def self.included(base)
        base.before do
          Logux::Test::Store.instance.reset!
        end
      end

      def logux_store
        Logux::Test::Store.instance.data
      end

      def send_to_logux(*commands)
        Logux::Test::Matchers::SendToLogux.new(*commands)
      end

      def a_logux_meta_with(attributes = {})
        RSpec::Matchers::BuiltIn::Include.new(attributes.stringify_keys)
      end
      alias a_logux_meta a_logux_meta_with

      def a_logux_action_with(attributes = {})
        RSpec::Matchers::BuiltIn::Include.new(attributes.stringify_keys)
      end
      alias a_logux_action a_logux_action_with

      def logux_approved(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['approved'], excludes: %w[forbidden error]
        )
      end

      def logux_processed(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['processed'], excludes: %w[forbidden error]
        )
      end

      def logux_forbidden(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['forbidden']
        )
      end

      def logux_errored(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['error']
        )
      end

      def logux_authenticated(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['authenticated']
        )
      end

      def logux_unauthorized(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['unauthorized']
        )
      end

      def logux_denied(meta = nil)
        Logux::Test::Matchers::ResponseChunks.new(
          meta: meta, includes: ['denied']
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logux-rack-0.1.0 lib/logux/test/helpers.rb