Sha256: 22d08f096584758cd9d52ac29ad5b747674042ff8347e1cccaf3681f7a82c817

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe RSpec::Grape::Entity::Matchers::HaveFormattingMatcher do
  include RSpec::Grape::Entity::Matchers::HaveFormattingMatcher

  let(:entity) { TestEntity }
  let(:object) do
    OpenStruct.new created_at: Time.utc(2022, 1, 22, 17, 0, 0),
                   updated_at: Time.utc(2022, 2, 4, 6, 0, 0)
  end

  context "when formatter is a symbol" do
    subject(:exposure) { entity.find_exposure :updated_at }

    it { is_expected.to have_formatting :iso_timestamp }
  end

  context "when formatter is a block" do
    subject(:exposure) { entity.find_exposure :created_at }

    it { is_expected.to have_formatting("2022-01-22T17:00:00Z").with_object(object) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-grape-entity-0.1.0 spec/matchers/have_formatting_matcher_spec.rb