-
Notifications
You must be signed in to change notification settings - Fork 49
/
ebayr_test.rb
91 lines (79 loc) · 2.78 KB
/
ebayr_test.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- encoding : utf-8 -*-
require 'test_helper'
require 'ebayr'
require 'fakeweb'
class FakeWeb::StubSocket
def close; end
end
describe Ebayr do
before { Ebayr.sandbox = true }
def check_common_methods(mod = Ebayr)
assert_respond_to mod, :"dev_id"
assert_respond_to mod, :"dev_id="
assert_respond_to mod, :"cert_id"
assert_respond_to mod, :"cert_id="
assert_respond_to mod, :"ru_name"
assert_respond_to mod, :"ru_name="
assert_respond_to mod, :"auth_token"
assert_respond_to mod, :"auth_token="
assert_respond_to mod, :"compatability_level"
assert_respond_to mod, :"compatability_level="
assert_respond_to mod, :"site_id"
assert_respond_to mod, :"site_id="
assert_respond_to mod, :"sandbox"
assert_respond_to mod, :"sandbox="
assert_respond_to mod, :"sandbox?"
assert_respond_to mod, :"authorization_callback_url"
assert_respond_to mod, :"authorization_callback_url="
assert_respond_to mod, :"authorization_failure_url"
assert_respond_to mod, :"authorization_failure_url="
assert_respond_to mod, :"callbacks"
assert_respond_to mod, :"callbacks="
assert_respond_to mod, :"logger"
assert_respond_to mod, :"logger="
assert_respond_to mod, :"uri"
end
# If this passes without an exception, then we're ok.
describe "basic usage" do
before { FakeWeb.register_uri(:post, Ebayr.uri, :body => xml) }
let(:xml) { "<GeteBayOfficialTimeResponse><Ack>Succes</Ack><Timestamp>blah</Timestamp></GeteBayOfficialTimeResponse>" }
it "runs without exceptions" do
Ebayr.call(:GeteBayOfficialTime).timestamp.must_equal 'blah'
end
end
it "correctly reports its sandbox status" do
Ebayr.sandbox = false
Ebayr.wont_be :sandbox?
Ebayr.sandbox = true
Ebayr.must_be :sandbox?
end
it "has the right sandbox URIs" do
Ebayr.must_be :sandbox?
Ebayr.uri_prefix.must_equal "https://api.sandbox.ebay.com/ws"
Ebayr.uri_prefix("blah").must_equal "https://blah.sandbox.ebay.com/ws"
Ebayr.uri.to_s.must_equal "https://api.sandbox.ebay.com/ws/api.dll"
end
it "has the right real-world URIs" do
Ebayr.sandbox = false
Ebayr.uri_prefix.must_equal "https://api.ebay.com/ws"
Ebayr.uri_prefix("blah").must_equal "https://blah.ebay.com/ws"
Ebayr.uri.to_s.must_equal "https://api.ebay.com/ws/api.dll"
Ebayr.sandbox = true
end
it "works when as an extension" do
mod = Module.new { extend Ebayr }
check_common_methods(mod)
end
it "works as an inclusion" do
mod = Module.new { extend Ebayr }
check_common_methods(mod)
end
it "has the right methods" do
check_common_methods
end
it "has decent defaults" do
Ebayr.must_be :sandbox?
Ebayr.uri.to_s.must_equal "https://api.sandbox.ebay.com/ws/api.dll"
Ebayr.logger.must_be_kind_of Logger
end
end