oass 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ describe Oass::Client do
17
17
  end
18
18
 
19
19
  describe "#request" do
20
- use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
20
+ use_vcr_cassette
21
21
 
22
22
  let(:client) { Oass::Client.new }
23
23
 
@@ -49,7 +49,7 @@ describe Oass::Client do
49
49
  end
50
50
 
51
51
  describe "#read_campaign" do
52
- use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
52
+ use_vcr_cassette
53
53
 
54
54
  let(:client) { Oass::Client.new }
55
55
 
@@ -69,7 +69,7 @@ describe Oass::Client do
69
69
  end
70
70
 
71
71
  describe "#read_creative" do
72
- use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
72
+ use_vcr_cassette
73
73
 
74
74
  let(:client) { Oass::Client.new }
75
75
 
@@ -95,31 +95,61 @@ describe Oass::Client do
95
95
  end
96
96
 
97
97
  describe "#create_campaign" do
98
- use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
98
+ use_vcr_cassette
99
99
 
100
100
  let(:client) { Oass::Client.new }
101
101
 
102
102
  context "with the required attributes" do
103
103
  let(:attributes) do
104
104
  {
105
- :id => "random_id_lolwut_wtf",
105
+ :id => "random_id_lolwut_wtf_shit",
106
106
  :name => "LOLWUT",
107
107
  :advertiser_id => "bobo",
108
108
  :agency_id => "unknown_agency",
109
109
  :name => "LOLWUT",
110
110
  :campaign_manager => "lol",
111
111
  :product_id => "default-product",
112
+ :schedule => {
113
+ :impressions => 999,
114
+ :clicks => 0,
115
+ :uniques => 0,
116
+ :weight => 10,
117
+ :priority_level => 1,
118
+ :completion => "E",
119
+ :start_date => "2005-12-01",
120
+ :end_date => "2040-12-01",
121
+ :reach => "O",
122
+ :daily_impressions => 99,
123
+ :daily_clicks => 9,
124
+ :daily_uniq => 1,
125
+ :smooth_or_asap => "S",
126
+ :impression_overrun => 2,
127
+ :companion_positions => %w(B/T BL/TL),
128
+ :strict_companions => "Y",
129
+ :hours_of_day => %w(00 01 23),
130
+ :days_of_week => %w(2 3 4 5),
131
+ :user_time_zone => "Y",
132
+ :sections => %w(SectionABC SectionDEF)
133
+ }
112
134
  }
113
135
  end
114
136
 
115
137
  subject { client.create_campaign attributes }
116
138
 
117
- its(:content) { "Successfully added." }
139
+ its(:content) { should == "Successfully added." }
140
+ end
141
+
142
+ context "with invalid attributes" do
143
+ use_vcr_cassette "Invalid campaign movie"
144
+
145
+ it "raises an OasError" do
146
+ expect { client.create_campaign :invalid => true }.to raise_error(Oass::OASError)
147
+ end
118
148
  end
119
149
  end
120
150
 
121
- describe "#create_criative" do
122
- use_vcr_cassette :record => :new_episodes, :match_requests_on => [:uri, :method, :body]
151
+ describe "#create_creative" do
152
+ use_vcr_cassette
123
153
 
124
154
  let(:client) { Oass::Client.new }
125
155
 
@@ -127,7 +157,7 @@ describe Oass::Client do
127
157
  let(:attributes) do
128
158
  {
129
159
  :campaign_id => "random_id_lolwut",
130
- :id => "I_am_so_creative_lol",
160
+ :id => "I_am_so_creative_lolwut",
131
161
  :name => "A nice name indeed",
132
162
  :description => "Blabla",
133
163
  :click_url => "http://lolwut.com",
@@ -150,12 +180,60 @@ describe Oass::Client do
150
180
  :browser_versions => %w(explorer6 netscape7),
151
181
  :sequence_number => "4"
152
182
  }
183
+ end
184
+
185
+ subject { client.create_creative attributes }
186
+
187
+ its(:content) { should == "Successfully added." }
188
+ end
189
+
190
+ context "with a creative file" do
191
+ use_vcr_cassette :record => :once
153
192
 
193
+ let(:attributes) do
194
+ {
195
+ :campaign_id => "random_id_lolwut",
196
+ :id => "creative_with_a_creative_lol",
197
+ :name => "A nice name indeed",
198
+ :description => "Blabla",
199
+ :click_url => "http://lolwut.com",
200
+ :positions => %w(TopLeft BottomLeft),
201
+ :creative_types_id => "unknow_type",
202
+ :redirect_url => "http://lolwut.com",
203
+ :display => "Y",
204
+ :height => "30",
205
+ :width => "30",
206
+ :target_window => "targetwindow",
207
+ :alt_text => "Oh hai!",
208
+ :discount_impressions => "N",
209
+ :start_date => "1986-03-31",
210
+ :end_date => "2040-03-31",
211
+ :weight => "79",
212
+ :expire_immediately => "N",
213
+ :no_cache => "N",
214
+ :extra_html => "<b></b>",
215
+ :extra_text => "kthxbai",
216
+ :browser_versions => %w(explorer6 netscape7),
217
+ :sequence_number => "4",
218
+ :creative_file => {
219
+ :name => "image.png",
220
+ :content_type => "image/png",
221
+ :file => File.join(File.dirname(__FILE__), "../fixtures/creative_file.png")
222
+ }
223
+ }
154
224
  end
155
225
 
156
226
  subject { client.create_creative attributes }
157
227
 
158
- its(:content) { "Successfully added." }
228
+ its(:content) { should == "Successfully added." }
229
+ end
230
+
231
+ context "with invalid attributes" do
232
+ use_vcr_cassette "Invalid creative movie"
233
+
234
+ it "raises an OasError" do
235
+ expect { client.create_creative :invalid => true }.to raise_error(Oass::OASError)
236
+ end
159
237
  end
160
238
  end
161
239
  end
@@ -6,6 +6,14 @@ describe Oass do
6
6
  it "allows configuration for #{setting}" do
7
7
  expect { Oass.send("#{setting}=", "LOL") }.to change { Oass.send(setting) }.to("LOL")
8
8
  end
9
+
10
+ it "provides #{setting} in the configuration block" do
11
+ expect {
12
+ Oass.configure { |config|
13
+ config.send("#{setting}=", "WUT")
14
+ }
15
+ }.to change { Oass.send(setting) }.to("WUT")
16
+ end
9
17
  end
10
18
  end
11
19
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,16 @@
1
1
  require 'oass'
2
2
  require 'vcr'
3
3
 
4
+ Dir[File.join("spec/support/**/*.rb")].each { |f| require f }
5
+
4
6
  VCR.config do |config|
5
7
  config.cassette_library_dir = File.join("spec/fixtures/vcr_cassettes")
6
8
  config.stub_with :webmock
9
+ config.default_cassette_options = {
10
+ :record => :new_episodes,
11
+ :match_requests_on => [:uri, :method, :body],
12
+ :erb => { :username => ENV["OAS_USERNAME"], :password => ENV["OAS_PASSWORD"], :account => ENV["OAS_ACCOUNT"] }
13
+ }
7
14
  end
8
15
 
9
16
  RSpec.configure do |config|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rodrigo Navarro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-25 00:00:00 -03:00
18
+ date: 2011-05-26 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -81,12 +81,18 @@ files:
81
81
  - README.md
82
82
  - Rakefile
83
83
  - lib/oass.rb
84
- - lib/oass/campaign.rb
85
84
  - lib/oass/client.rb
86
- - lib/oass/creative.rb
85
+ - lib/oass/client/campaign.rb
86
+ - lib/oass/client/creative.rb
87
87
  - lib/oass/errors.rb
88
88
  - lib/oass/version.rb
89
89
  - oass.gemspec
90
+ - spec/fixtures/creative_file.png
91
+ - spec/fixtures/vcr_cassettes/Invalid_campaign_movie.yml
92
+ - spec/fixtures/vcr_cassettes/Invalid_creative_movie.yml
93
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_campaign.yml
94
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_creative.yml
95
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_creative/with_a_creative_file.yml
90
96
  - spec/fixtures/vcr_cassettes/Oass_Client/_read_campaign.yml
91
97
  - spec/fixtures/vcr_cassettes/Oass_Client/_read_creative.yml
92
98
  - spec/fixtures/vcr_cassettes/Oass_Client/_request.yml
@@ -128,6 +134,12 @@ signing_key:
128
134
  specification_version: 3
129
135
  summary: Funny API to access OAS hellish soap interface
130
136
  test_files:
137
+ - spec/fixtures/creative_file.png
138
+ - spec/fixtures/vcr_cassettes/Invalid_campaign_movie.yml
139
+ - spec/fixtures/vcr_cassettes/Invalid_creative_movie.yml
140
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_campaign.yml
141
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_creative.yml
142
+ - spec/fixtures/vcr_cassettes/Oass_Client/_create_creative/with_a_creative_file.yml
131
143
  - spec/fixtures/vcr_cassettes/Oass_Client/_read_campaign.yml
132
144
  - spec/fixtures/vcr_cassettes/Oass_Client/_read_creative.yml
133
145
  - spec/fixtures/vcr_cassettes/Oass_Client/_request.yml
data/lib/oass/campaign.rb DELETED
@@ -1,35 +0,0 @@
1
- module Oass
2
- module Campaign
3
- def read_campaign(id)
4
- request "Campaign" do |xml|
5
- xml.Campaign(:action => "read") do
6
- xml.Overview { xml.Id id }
7
- end
8
- end
9
- end
10
-
11
- def create_campaign(attributes)
12
- request "Campaign" do |xml|
13
- xml.Campaign(:action => "add") do
14
- xml.Overview do
15
- # Yeah... the attributes must be in the right order =/
16
- xml.Id attributes[:id]
17
- xml.AdvertiserId attributes[:advertiser_id]
18
- xml.Name attributes[:name]
19
- xml.AgencyId attributes[:agency_id]
20
- xml.Description attributes[:description]
21
- xml.CampaignManager attributes[:campaign_manager]
22
- xml.ProductId attributes[:product_id]
23
- xml.ExternalUsers do
24
- attributes[:external_users].each do |user_id|
25
- xml.UserId user_id
26
- end
27
- end if attributes[:external_users]
28
- xml.InternalQuickReport attributes[:internal_quick_report]
29
- xml.ExternalQuickReport attributes[:external_quick_report]
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
data/lib/oass/creative.rb DELETED
@@ -1,50 +0,0 @@
1
- module Oass
2
- module Creative
3
- def read_creative(campaign_id, id)
4
- request "Creative" do |xml|
5
- xml.Creative(:action => "read") do
6
- xml.CampaignId campaign_id
7
- xml.Id id
8
- end
9
- end
10
- end
11
-
12
- def create_creative(attributes)
13
- request "Creative" do |xml|
14
- xml.Creative(:action => "add") do
15
- xml.CampaignId attributes[:campaign_id]
16
- xml.Id attributes[:id]
17
- xml.Name attributes[:name]
18
- xml.Description attributes[:description]
19
- xml.ClickUrl attributes[:click_url]
20
- xml.Positions do
21
- attributes[:positions].each do |position|
22
- xml.Position position
23
- end
24
- end
25
- xml.CreativeTypesId attributes[:creative_types_id]
26
- xml.RedirectUrl attributes[:redirect_url]
27
- xml.Display attributes[:display]
28
- xml.Height attributes[:height]
29
- xml.Width attributes[:width]
30
- xml.TargetWindow attributes[:target_window]
31
- xml.AltText attributes[:alt_text]
32
- xml.DiscountImpressions attributes[:discount_impressions]
33
- xml.StartDate attributes[:start_date]
34
- xml.EndDate attributes[:end_date]
35
- xml.Weight attributes[:weight]
36
- xml.ExpireImmediately attributes[:expire_immediately]
37
- xml.NoCache attributes[:no_cache]
38
- xml.ExtraHTML attributes[:extra_html]
39
- xml.ExtraText attributes[:extra_text]
40
- xml.BrowserV do
41
- attributes[:browser_versions].each do |version|
42
- xml.Code version
43
- end
44
- end
45
- xml.SequenceNo attributes[:sequence_number]
46
- end
47
- end
48
- end
49
- end
50
- end