Sha256: 6d84badc7f9480df71ef753929d57e1f1111baf3e50ef44aff7b9c41bb455be8

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Cardflex::Http do
  describe '_verify_ssl_certificate' do
    it 'should fail verification if preverify is false' do
      context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
      sut = Cardflex::Configuration.instantiate.http._verify_ssl_certificate(false, context)
      expect(sut).to eq false
    end

    it 'should fail verification if context has an error' do
      context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
      context.error = 0
      sut = Cardflex::Configuration.instantiate.http._verify_ssl_certificate(false, context)
      expect(sut).to eq false
    end

    it 'should convert a hash to a query string' do
      http = Cardflex::Configuration.instantiate.http
      result = http._hash_to_query_string(:field1 => 'test', :field2 => 'test')
      expect(result).to eq "?field1=test&field2=test"
    end

    it 'should convert an array to comma separated string values' do
      http = Cardflex::Configuration.instantiate.http
      result = http._hash_to_query_string(:field1 => ["a", "b", "c"])
      expect(result).to eq "?field1=a,b,c"
    end

    it 'should not convert a nested hash' do
      http = Cardflex::Configuration.instantiate.http
      result = http._hash_to_query_string(:field1 => 'test', :field2 => { :field3 => "a" })
      expect(result).to eq "?field1=test"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cardflex-ruby-0.1.2 spec/unit/cardflex/http_spec.rb
cardflex-ruby-0.1.1 spec/unit/cardflex/http_spec.rb