require File.dirname(__FILE__) + "/../test_helper" class JsonEncodingTest < Test::Unit::TestCase def test_basic_request_encoding r = EWS::Transaction::Request.new(basic_params) json = EWS::Transaction::Mapping.request_to_json(r) res = ActiveSupport::JSON.decode(json) assert_equal "10.13", res["amount"] assert_equal "Simon Brown", res["cardholder_name"] assert_equal "4111111111111111", res["cc_number"] assert_equal "1012", res["cc_expiry"] end def test_request_encoding_everything request = EWS::Transaction::Request.new(sample_everything_params) json = EWS::Transaction::Mapping.request_to_json(request) res = ActiveSupport::JSON.decode(json) sample_everything_params.keys.each do |k| assert_equal request.send(k), res[k.to_s] end end def test_response_decoding payload = <