Sha256: ea5f1c5c9645c932a1ea8a202c17d9f5f3e0d1d7e191b3bad66038d9d8b728c0

Contents?: true

Size: 782 Bytes

Versions: 8

Compression:

Stored size: 782 Bytes

Contents

require "cgi"
require "spec_helper"

RSpec.describe Digicert::Util do
  describe ".to_query" do
    context "plain hash with key and value" do
      it "builds and returns the queryable params" do
        params = { limit: 10, sort: "date_created" }
        query_params = Digicert::Util.to_query(params)

        expect(query_params).to eq("limit=10&sort=date_created")
      end
    end

    context "with nested hash as key" do
      it "resolves it and returns the queryable params" do
        params = { limit: 10, filters: { status: "issued", search: "ribose" } }
        query_params = Digicert::Util.to_query(params)

        expect(
          CGI.unescape(query_params),
        ).to eq("limit=10&filters[status]=issued&filters[search]=ribose")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
digicert-1.0.0 spec/digicert/util_spec.rb
digicert-0.5.0 spec/digicert/util_spec.rb
digicert-0.4.1 spec/digicert/util_spec.rb
digicert-0.4.0 spec/digicert/util_spec.rb
digicert-0.3.1 spec/digicert/util_spec.rb
digicert-0.3.0 spec/digicert/util_spec.rb
digicert-0.2.0 spec/digicert/util_spec.rb
digicert-0.1.2 spec/digicert/util_spec.rb