Sha256: 7cfee46af90d92e89adb196f616590ca231293be74ad5beb022a86ac456aaa1a

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'
require 'adyen/rest/request'

class RESTRequestTest < Minitest::Test

  def setup
    @attributes = {
      test: 123,
      nested: {
        camel_case: '456',
      },

    }
  end

  def test_form_data
    request = Adyen::REST::Request.new('Action.Test', @attributes)

    form_data = request.form_data
    assert_equal '123',  form_data['test']
    assert_equal '456',  form_data['nested.camelCase']
  end

  def test_setting_attributes
    request = Adyen::REST::Request.new('Action.Test', @attributes)
    request[:nested] = { a: 1, b: 2 }
    request[:c] = 'hello world'
    request[:camel_case] = 'snake_case'

    assert_equal '1', request.form_data['nested.a']
    assert_equal '2', request.form_data['nested.b']
    assert_equal 'hello world', request.form_data['c']
    assert_equal 'snake_case', request.form_data['camelCase']
  end

  def test_getting_attributes
    request = Adyen::REST::Request.new('Action.Test', @attributes)
    assert_equal '123', request['test']
    assert_equal '123', request[:test]
    assert_equal '456', request['nested.camel_case']
    assert_equal '456', request['nested.camelCase']
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adyen_jpiqueras-2.5.0 test/rest_request_test.rb
adyen_jpiqueras-2.4.0 test/rest_request_test.rb
adyen_jpiqueras-2.3.0 test/rest_request_test.rb