Sha256: 2651b6d9da7e0745ab8379cdc6b8df8fed36351767491a0d008daa6f5fb199dc

Contents?: true

Size: 1.1 KB

Versions: 28

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

class FakeClass
  include FinApps::Utils::QueryBuilder

  def build_filter(param); end
end

RSpec.describe FinApps::Utils::QueryBuilder do
  subject { FakeClass.new }

  describe '#build_query_path' do
    let(:end_point) { 'orders' }

    context 'with full params' do
      let(:params) do
        { page: '1', requested: '20', sort: '-date', random: 'random' }
      end
      it 'calls #build_filter and returns correct string' do
        allow(subject).to receive(:build_filter) { { role: 2 } }
        expect(subject).to receive(:build_filter).with(params)
        correct_string =
          'orders?page=1&requested=20&sort=-date&filter=%7B%22role%22%3A2%7D'
        expect(subject.build_query_path(end_point, params)).to eq(
          correct_string
        )
      end
    end

    context 'with no params' do
      let(:params) { {} }
      it 'returns root' do
        allow(subject).to receive(:build_filter) { {} }
        expect(subject).to receive(:build_filter).with(params)
        expect(subject.build_query_path(end_point, params)).to eq(end_point)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
finapps-5.0.32 spec/utils/query_builder_spec.rb
finapps-5.0.31 spec/utils/query_builder_spec.rb
finapps-5.0.30 spec/utils/query_builder_spec.rb
finapps-5.0.29 spec/utils/query_builder_spec.rb
finapps-5.0.28 spec/utils/query_builder_spec.rb
finapps-5.0.27 spec/utils/query_builder_spec.rb
finapps-5.0.26 spec/utils/query_builder_spec.rb
finapps-5.0.25 spec/utils/query_builder_spec.rb
finapps-5.0.24 spec/utils/query_builder_spec.rb
finapps-5.0.23 spec/utils/query_builder_spec.rb
finapps-5.0.22 spec/utils/query_builder_spec.rb
finapps-5.0.21 spec/utils/query_builder_spec.rb
finapps-5.0.20 spec/utils/query_builder_spec.rb
finapps-5.0.19 spec/utils/query_builder_spec.rb
finapps-5.0.17 spec/utils/query_builder_spec.rb
finapps-5.0.16 spec/utils/query_builder_spec.rb
finapps-5.0.15 spec/utils/query_builder_spec.rb
finapps-5.0.14 spec/utils/query_builder_spec.rb
finapps-5.0.13 spec/utils/query_builder_spec.rb
finapps-5.0.12 spec/utils/query_builder_spec.rb