oas 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_client.rb CHANGED
@@ -1,91 +1,90 @@
1
- require 'helper'
2
- require 'webmock'
3
-
4
- class TestClient < MiniTest::Unit::TestCase
5
- include WebMock::API
6
-
7
- def setup
8
- @client = OAS::Client.new(
9
- :account => "test_account",
10
- :username => "test_user",
11
- :password => "test_password"
12
- )
13
- @request = Class.new do
14
- def to_xml; '<AdXML></AdXML>' end
15
- end.new
16
- end
17
-
18
- def teardown
19
- OAS.reset!
20
- WebMock.reset!
21
- end
22
-
23
- def fixture(file)
24
- File.new(File.join(File.expand_path('../fixtures', __FILE__), file))
25
- end
26
-
27
- def test_execute_request
28
- stub_request(:post, @client.endpoint.to_s)
29
- .to_return(:status => 200, :body => fixture('response.xml'))
30
-
31
- assert_kind_of OAS::AdXML, @client.execute(@request)
32
- assert_requested(:post, @client.endpoint.to_s, :times => 1) do |req|
33
- doc = Nokogiri.XML(req.body)
34
- node = doc.xpath("/env:Envelope/env:Body/n1:OasXmlRequest").first
35
- return false unless !!node
36
- node.xpath("./String_1").first.text == @client.account &&
37
- node.xpath("./String_2").first.text == @client.username &&
38
- node.xpath("./String_3").first.text == @client.password &&
39
- node.xpath("./String_4").first.text == @request.to_xml
40
- end
41
- end
42
-
43
-
44
- def test_raise_http_error
45
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 599)
46
-
47
- assert_raises OAS::Error::HTTP do
48
- @client.execute(@request)
49
- end
50
- end
51
-
52
- def test_raise_http_forbidden_error
53
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 403)
54
-
55
- assert_raises OAS::Error::HTTP::Forbidden do
56
- @client.execute(@request)
57
- end
58
- end
59
-
60
- def test_raise_http_internal_server_error_error
61
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 500)
62
-
63
- assert_raises OAS::Error::HTTP::InternalServerError do
64
- @client.execute(@request)
65
- end
66
- end
67
-
68
- def test_raise_http_bad_gateway_error
69
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 502)
70
-
71
- assert_raises OAS::Error::HTTP::BadGateway do
72
- @client.execute(@request)
73
- end
74
- end
75
-
76
- def test_raise_http_service_unavailable_error
77
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 503)
78
-
79
- assert_raises OAS::Error::HTTP::ServiceUnavailable do
80
- @client.execute(@request)
81
- end
82
- end
83
-
84
- def test_raise_http_gateway_timeout_error
85
- stub_request(:post, @client.endpoint.to_s).to_return(:status => 504)
86
-
87
- assert_raises OAS::Error::HTTP::GatewayTimeout do
88
- @client.execute(@request)
89
- end
90
- end
1
+ require 'helper'
2
+ require 'webmock'
3
+
4
+ class TestClient < MiniTest::Unit::TestCase
5
+ include WebMock::API
6
+
7
+ def setup
8
+ @client = OAS::Client.new(
9
+ :account => "test_account",
10
+ :username => "test_user",
11
+ :password => "test_password"
12
+ )
13
+ @request = Class.new do
14
+ def to_xml; '<AdXML></AdXML>' end
15
+ end.new
16
+ end
17
+
18
+ def teardown
19
+ OAS.reset!
20
+ WebMock.reset!
21
+ end
22
+
23
+ def fixture(file)
24
+ File.new(File.join(File.expand_path('../fixtures', __FILE__), file))
25
+ end
26
+
27
+ def test_execute_request
28
+ stub_request(:post, @client.endpoint.to_s)
29
+ .to_return(:status => 200, :body => fixture('response.xml'))
30
+
31
+ assert_kind_of OAS::AdXML, @client.execute(@request)
32
+ assert_requested(:post, @client.endpoint.to_s, :times => 1) do |req|
33
+ doc = Nokogiri.XML(req.body)
34
+ node = doc.xpath("/env:Envelope/env:Body/n1:OasXmlRequest").first
35
+ return false unless !!node
36
+ node.xpath("./String_1").first.text == @client.account &&
37
+ node.xpath("./String_2").first.text == @client.username &&
38
+ node.xpath("./String_3").first.text == @client.password &&
39
+ node.xpath("./String_4").first.text == @request.to_xml
40
+ end
41
+ end
42
+
43
+ def test_raise_http_error
44
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 599)
45
+
46
+ assert_raises OAS::Error::HTTP do
47
+ @client.execute(@request)
48
+ end
49
+ end
50
+
51
+ def test_raise_http_forbidden_error
52
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 403)
53
+
54
+ assert_raises OAS::Error::HTTP::Forbidden do
55
+ @client.execute(@request)
56
+ end
57
+ end
58
+
59
+ def test_raise_http_internal_server_error_error
60
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 500)
61
+
62
+ assert_raises OAS::Error::HTTP::InternalServerError do
63
+ @client.execute(@request)
64
+ end
65
+ end
66
+
67
+ def test_raise_http_bad_gateway_error
68
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 502)
69
+
70
+ assert_raises OAS::Error::HTTP::BadGateway do
71
+ @client.execute(@request)
72
+ end
73
+ end
74
+
75
+ def test_raise_http_service_unavailable_error
76
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 503)
77
+
78
+ assert_raises OAS::Error::HTTP::ServiceUnavailable do
79
+ @client.execute(@request)
80
+ end
81
+ end
82
+
83
+ def test_raise_http_gateway_timeout_error
84
+ stub_request(:post, @client.endpoint.to_s).to_return(:status => 504)
85
+
86
+ assert_raises OAS::Error::HTTP::GatewayTimeout do
87
+ @client.execute(@request)
88
+ end
89
+ end
91
90
  end
@@ -1,12 +1,12 @@
1
- require 'helper'
2
-
3
- class TestConfiguration < MiniTest::Unit::TestCase
4
- def test_should_set_configuration_keys
5
- OAS::Configuration::VALID_OPTIONS_KEYS.each do |key|
6
- OAS.configure do |config|
7
- config.send("#{key}=", key)
8
- assert_equal key, OAS.send(key)
9
- end
10
- end
11
- end
1
+ require 'helper'
2
+
3
+ class TestConfiguration < MiniTest::Unit::TestCase
4
+ def test_should_set_configuration_keys
5
+ OAS::Configuration::VALID_OPTIONS_KEYS.each do |key|
6
+ OAS.configure do |config|
7
+ config.send("#{key}=", key)
8
+ assert_equal key, OAS.send(key)
9
+ end
10
+ end
11
+ end
12
12
  end
@@ -1,38 +1,38 @@
1
- require 'helper'
2
-
3
- class TestAdXMLResponse < MiniTest::Unit::TestCase
4
- def test_successful_response
5
- node = <<-EOXML
6
- <AdXML>
7
- <Response>
8
- <Campaign>
9
- <Overview>
10
- <Id>DPtestcampaign-01</Id>
11
- </Overview>
12
- </Campaign>
13
- </Response>
14
- </AdXML>
15
- EOXML
16
- res = OAS::AdXML::Response.new Nokogiri.XML(node).xpath('/AdXML/Response').first
17
- assert res.to_hash.has_key?(:Response)
18
- assert res.success?
19
- assert_nil res.error_code
20
- assert_nil res.error_text
21
- end
22
-
23
- def test_unsuccessful_response
24
- node = <<-EOXML
25
- <AdXML>
26
- <Response>
27
- <Campaign>
28
- <Exception errorCode="512">Campaign ID already exists in Open AdStream</Exception>
29
- </Campaign>
30
- </Response>
31
- </AdXML>
32
- EOXML
33
- res = OAS::AdXML::Response.new Nokogiri.XML(node).xpath('/AdXML/Response').first
34
- refute res.success?
35
- assert_equal 512, res.error_code
36
- assert_equal 'Campaign ID already exists in Open AdStream', res.error_text
37
- end
1
+ require 'helper'
2
+
3
+ class TestAdXMLResponse < MiniTest::Unit::TestCase
4
+ def test_successful_response
5
+ node = <<-EOXML
6
+ <AdXML>
7
+ <Response>
8
+ <Campaign>
9
+ <Overview>
10
+ <Id>DPtestcampaign-01</Id>
11
+ </Overview>
12
+ </Campaign>
13
+ </Response>
14
+ </AdXML>
15
+ EOXML
16
+ res = OAS::AdXML::Response.new Nokogiri.XML(node).xpath('/AdXML/Response').first
17
+ assert res.to_hash.has_key?(:Response)
18
+ assert res.success?
19
+ assert_nil res.error_code
20
+ assert_nil res.error_text
21
+ end
22
+
23
+ def test_unsuccessful_response
24
+ node = <<-EOXML
25
+ <AdXML>
26
+ <Response>
27
+ <Campaign>
28
+ <Exception errorCode="512">Campaign ID already exists in Open AdStream</Exception>
29
+ </Campaign>
30
+ </Response>
31
+ </AdXML>
32
+ EOXML
33
+ res = OAS::AdXML::Response.new Nokogiri.XML(node).xpath('/AdXML/Response').first
34
+ refute res.success?
35
+ assert_equal 512, res.error_code
36
+ assert_equal 'Campaign ID already exists in Open AdStream', res.error_text
37
+ end
38
38
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
5
- prerelease:
4
+ version: 2.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Damian Caruso
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.5'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.5'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: nori
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '2.0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '2.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: savon
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '2.0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '2.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0.9'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0.9'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: webmock
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '1.9'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '1.9'
94
83
  description: Ruby client for the OpenAdstream API
@@ -98,8 +87,8 @@ executables: []
98
87
  extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
- - .gitignore
102
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
103
92
  - Gemfile
104
93
  - LICENSE
105
94
  - README.md
@@ -120,32 +109,25 @@ files:
120
109
  homepage: http://github.com/realmedia/oas-ruby-client
121
110
  licenses:
122
111
  - MIT
112
+ metadata: {}
123
113
  post_install_message:
124
114
  rdoc_options: []
125
115
  require_paths:
126
116
  - lib
127
117
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
118
  requirements:
130
- - - ! '>='
119
+ - - ">="
131
120
  - !ruby/object:Gem::Version
132
121
  version: '0'
133
- segments:
134
- - 0
135
- hash: -872956227
136
122
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
123
  requirements:
139
- - - ! '>='
124
+ - - ">="
140
125
  - !ruby/object:Gem::Version
141
126
  version: '0'
142
- segments:
143
- - 0
144
- hash: -872956227
145
127
  requirements: []
146
128
  rubyforge_project: oas
147
- rubygems_version: 1.8.24
129
+ rubygems_version: 2.2.2
148
130
  signing_key:
149
- specification_version: 3
131
+ specification_version: 4
150
132
  summary: Ruby client for the OpenAdstream API
151
133
  test_files: []