Sha256: 089161f482a970cfc6825bf56646f2634bc7c30b7656dda3be2e0ac9c80710fe

Contents?: true

Size: 887 Bytes

Versions: 8

Compression:

Stored size: 887 Bytes

Contents

require_relative '../../spec_helper'
include OpenpayUtils

describe OpenpayUtils do

  describe SearchParams do

    subject(:search_params) { SearchParams.new }

    describe 'setters and getters' do

      it 'sets and gets a given value' do
        val = "val"
        search_params.val = val
        expect(search_params.val).to eq(val)
      end

      it 'sets and gets a non existing attribute' do
        expect(search_params.val).to eq(nil)
      end
    end

    describe '.to_s' do
      it 'generates the filter string based on the attributes' do
        creation_date = "2013-11-01"
        search_params.creation_gte = creation_date
        limit = 2
        search_params.limit = limit
        amount = 100
        search_params.amount_lte = amount
        expect(search_params.to_s).to eq("?creation[gte]=2013-11-01&limit=2&amount[lte]=100")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
openpay-2.0.0 test/spec/utils/search_params_spec.rb
openpay-2.0.0b test/spec/utils/search_params_spec.rb
openpay-1.0.10 test/spec/utils/search_params_spec.rb
openpay-1.0.8 test/spec/utils/search_params_spec.rb
openpay-1.0.7 test/spec/utils/search_params_spec.rb
openpay-1.0.6 test/spec/utils/search_params_spec.rb
openpay-1.0.5 test/spec/utils/search_params_spec.rb
openpay-1.0.4 test/spec/utils/search_params_spec.rb