jjolma (owner)

Revisions

gist: 228224 Download_button fork
public
Public Clone URL: git://gist.github.com/228224.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'test_helper'
require 'mocha'
require 'active_resource'
require 'braintree_report'
 
class BraintreeReportTest < ActiveSupport::TestCase
 
  def setup
    FakeWeb.allow_net_connect = false
  end
 
  # Replace this with your real tests.
  test "raises unauthorized access if invalid username/password response" do
    FakeWeb.register_uri(:get,
                         "https://secure.braintreepaymentgateway.com/api/query.php/braintree_reports.xml",
                         :body => invalid_credentials_response)
 
    assert_raises ActiveResource::UnauthorizedAccess do
      report = BraintreeReport.find(:first, 'testapi', :params => { :password => 'password1', :order_id => '123'})
    end
  end
 
  protected
  def invalid_credentials_response
    <<-EOS
<?xml version="1.0" encoding="UTF-8"?>
<nm_response>
<error_response>Invalid Username/Password REFID:200402058</error_response>
</nm_response>
EOS
  end
 
end