Sha256: 43d11ca7806ad0aa3a7983512e8d9697d2f8f1662c6e8e920934acc23a618ae0

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

class FakeClass
  include FinApps::Utils::QueryBuilder

  def build_filter(p); 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) { {page: '1', requested: '20', sort: '-date', random: 'random'} }
      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 returns' do
        allow(subject).to receive(:build_filter) { {} }
        expect(subject).to receive(:build_filter).with(params)
        expect(subject.build_query_path(end_point, params)).to be_nil
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
finapps-4.0.3 spec/utils/query_builder_spec.rb
finapps-4.0.2 spec/utils/query_builder_spec.rb
finapps-4.0.1 spec/utils/query_builder_spec.rb
finapps-3.0.7 spec/utils/query_builder_spec.rb
finapps-3.0.6 spec/utils/query_builder_spec.rb
finapps-3.0.5 spec/utils/query_builder_spec.rb
finapps-3.0.4 spec/utils/query_builder_spec.rb
finapps-3.0.3 spec/utils/query_builder_spec.rb
finapps-3.0.2 spec/utils/query_builder_spec.rb
finapps-3.0.1 spec/utils/query_builder_spec.rb
finapps-2.3.7 spec/utils/query_builder_spec.rb
finapps-2.3.6 spec/utils/query_builder_spec.rb
finapps-2.3.5 spec/utils/query_builder_spec.rb