Sha256: 77eda9a5c7718ca2beedc0d59b2e08011f8d9e398d9fc7706f97739aae7eafef
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require 'spec_helper' require 'faraday' module Platon RSpec.describe FormService do describe '#call' do let(:params) { { data: { amount: '99.99', currency: 'UAH', description: 'description' }, extra: [{ name: 'name1', value: 'value1' }] } } subject { described_class.call(params[:data], order: 1) } it 'send request' do response = Faraday.post do |req| req.url subject.form_prop[:url] req.body = {}.tap do |body| subject.fields.each { |f| body[f[:name]] = f[:value] } end end expect(Nokogiri.parse(response.body).xpath('//div[@class="main"]').text.strip).not_to eq("Not enough input data") end end describe 'Compare with the reference value' do subject do Platon::Configure.cfg.account_key = '7LNR6TEHWF' Platon::Configure.cfg.callback_url ='http://localhost:3000/platon/callback' Platon::Configure.cfg.account_password = 'ExcNdmUj0zwxpHAnGbWUnhv0G04RRahV' described_class.call(params[:data], order: params[:order]) end let(:params) do { data: { amount: '99.99', currency: 'USD', description: 'Desc' }, order: 1 } end # Next values were generated by platon example php script (buy_platon.php) at the same data let(:ref_sign) { 'c006d7beb0a732a3bb637587ce7c8aef' } let(:ref_data_key) { 'eyJhbW91bnQiOiI5OS45OSIsImN1cnJlbmN5IjoiVVNEIiwiZGVzY3JpcHRpb24iOiJEZXNjIn0=' } it 'encrypted data is valid' do expect(subject.fields.find{ |_| _[:name] == 'data' }[:value]).to eq ref_data_key end it 'encrypted sing is valid' do expect(subject.fields.find{ |_| _[:name] == 'sign' }[:value]).to eq ref_sign end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
platon.ua-1.0.1 | spec/services/platon/platon_form_services_spec.rb |