Sha256: c627019a7dc3253c6bf8793c633aa12f2fdbf6b1a31a78e6fe87e9b65b0e5f27

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Buckaroo::Ideal::RequestSignature do
  it 'generates a signature for the given order' do
    order  = mock :invoice_number => 'EETNU-12345',
                  :amount         => 12.50,
                  :currency       => 'EUR'
    
    Buckaroo::Ideal::Config.stub(:test_mode).
                            and_return(true)
    
    Buckaroo::Ideal::Config.stub(:merchant_key).
                            and_return('merchant_key')
    
    Buckaroo::Ideal::Config.stub(:secret_key).
                            and_return('secret_key')
    
    signature = Buckaroo::Ideal::RequestSignature.new(order)
    
    expected_salt = [
      'merchant_key', # config.merchant_key
      'EETNU-12345',  # order.invoice_number
      1250,           # order.amount in cents
      'EUR',          # order.currency
      1,              # config.test_mode
      'secret_key'    # config.secret_key
    ].join
    
    Digest::MD5.should_receive(:hexdigest).
                            with(expected_salt)
    
    signature.to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buckaroo-ideal-0.0.2 spec/buckaroo-ideal/request_signature_spec.rb