akamai_api 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73cef131d80417eed0e7de2d302dfc742c3a858b
4
- data.tar.gz: c13ca6c1ee5a6b24521a186f717ab4f0e6d60e7a
3
+ metadata.gz: a91d1f5aebb3714f21a4983711443dc53d42c808
4
+ data.tar.gz: 55d3facb0f58d82c7f45e95476094a0162b9d1c8
5
5
  SHA512:
6
- metadata.gz: f6d2774462ee3b49ec37f6ff919141614febc88fce1b52e76f0f24084d41d72467243ab286030585689c8d6058ab141f9ff4cd1c4221374fc8e3f799d70810e7
7
- data.tar.gz: d9f1d79623c847db65875005a1ccd3061cb1cd64aaf03438e9e1103a93ac3c91019987624392ab7dd71fda2445abe192d1f13477db6436f973b5bd0494599309
6
+ metadata.gz: aaf0f4bd70819e4f9155a64557cb87c1c55c84a3ccc1d5161ffeadebbb3ea0da85c4aad9c336fce154c40793e5395c961265297bc3a82f40947616262d753f43
7
+ data.tar.gz: 93645a4059240cc6b97942f0d56ff5ca65ad90e69bb2e031f98d5d2aeeae2d411a4598acb3349e243fa96130793ac6b1ef8be76068890ee92ec459060599116c
@@ -8,13 +8,17 @@ module AkamaiApi
8
8
 
9
9
  class << self
10
10
  [:invalidate, :remove].each do |action|
11
- send :define_method, action do |type, items, args = {}|
12
- purge action, type, items, args
11
+ send :define_method, action do |*params|
12
+ raise ArgumentError, "wrong number of arguments (#{params.length} for 2..3)" if params.length < 2
13
+ type, items, opts = params
14
+ purge action, type, items, (opts || {})
13
15
  end
14
16
  [:arl, :cpcode].each do |type|
15
17
  method_name = "#{action}_#{type}".to_sym
16
- send :define_method, method_name do |items, args = {}|
17
- purge action, type, items, args
18
+ send :define_method, method_name do |*params|
19
+ raise ArgumentError, "wrong number of arguments (#{params.length} for 1..2)" if params.length < 1
20
+ items, opts = params
21
+ purge action, type, items, (opts || {})
18
22
  end
19
23
  end
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module AkamaiApi
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -9,28 +9,50 @@ module AkamaiApi
9
9
  stub_savon_model Ccu
10
10
  end
11
11
 
12
- describe '#purge response' do
13
- it 'is a CcuResponse object' do
14
- Ccu.remove_cpcode('12345').should be_a CcuResponse
12
+ shared_examples 'purge helper' do
13
+ it 'responds with a CcuResponse object' do
14
+ Ccu.send(method, '12345').should be_a CcuResponse
15
15
  end
16
16
 
17
- it 'returns code 100' do
18
- Ccu.remove_cpcode('12345').code.should == 100
19
- end
17
+ context 'when data are correct' do
18
+ it 'returns the expected response code' do
19
+ Ccu.send(method, '12345').code.should == 100
20
+ end
20
21
 
21
- it 'returns a success message' do
22
- Ccu.remove_cpcode('12345').message.should == 'Success.'
23
- end
22
+ it 'returns a successful message' do
23
+ Ccu.send(method, '12345').message.should == 'Success.'
24
+ end
24
25
 
25
- it 'returns a unique session id' do
26
- Ccu.remove_cpcode('12345').session_id.should == '97870328-018c-11e2-aabc-489beabc489b'
27
- end
26
+ it 'returns a unique session id' do
27
+ Ccu.send(method, '12345').session_id.should == '97870328-018c-11e2-aabc-489beabc489b'
28
+ end
28
29
 
29
- it 'returns the estimated time in seconds' do
30
- Ccu.remove_cpcode('12345').estimated_time.should == 420
30
+ it 'returns the estimated time in seconds' do
31
+ Ccu.send(method, '12345').estimated_time.should == 420
32
+ end
31
33
  end
32
34
  end
33
35
 
36
+ context '#invalidate_arl' do
37
+ let(:method) { 'invalidate_arl' }
38
+ it_should_behave_like 'purge helper'
39
+ end
40
+
41
+ context '#invalidate_cpcode' do
42
+ let(:method) { 'invalidate_cpcode' }
43
+ it_should_behave_like 'purge helper'
44
+ end
45
+
46
+ context '#remove_arl' do
47
+ let(:method) { 'remove_arl' }
48
+ it_should_behave_like 'purge helper'
49
+ end
50
+
51
+ context '#remove_cpcode' do
52
+ let(:method) { 'remove_cpcode' }
53
+ it_should_behave_like 'purge helper'
54
+ end
55
+
34
56
  describe '#purge raises an error when' do
35
57
  it 'action is not allowed' do
36
58
  %w(invalidate remove).each do |action|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akamai_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicola Racco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-29 00:00:00.000000000 Z
11
+ date: 2013-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport