Permalink
Browse files

Merge pull request #1 from groupme/parse_guid_from_kannel_response

Parse and set guid from kannel response
  • Loading branch information...
cmdrkeene committed Jan 23, 2012
2 parents 306d4cc + dad7075 commit dd86a96f3798c30e1fefa5b477b865d489200834
Showing with 27 additions and 12 deletions.
  1. +6 −4 Gemfile.lock
  2. +0 −4 README.md
  3. +4 −0 lib/em-kannel/response.rb
  4. +6 −1 lib/em-kannel/test_helper.rb
  5. +1 −1 lib/em-kannel/version.rb
  6. +10 −2 spec/em-kannel/response_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- em-kannel (0.1.0)
+ em-kannel (0.2.0)
activemodel (~> 3.1)
em-http-request (>= 1.0.0.beta.4)
eventmachine (>= 1.0.0.beta.3)
@@ -17,13 +17,15 @@ GEM
multi_json (~> 1.0)
addressable (2.2.6)
builder (3.0.0)
+ cookiejar (0.3.0)
crack (0.3.1)
diff-lcs (1.1.3)
- em-http-request (1.0.0)
+ em-http-request (1.0.1)
addressable (>= 2.2.3)
+ cookiejar
em-socksify
- eventmachine (>= 1.0.0.beta.3)
- http_parser.rb (>= 0.5.2)
+ eventmachine (>= 1.0.0.beta.4)
+ http_parser.rb (>= 0.5.3)
em-socksify (0.1.0)
eventmachine
eventmachine (1.0.0.beta.4)
View
@@ -60,7 +60,3 @@ list:
# Legal
See LICENSE for details
-
-# TODO
-
-* Parse Kannel responses
@@ -24,6 +24,10 @@ def error
@http.error
end
+ def guid
+ body.split(": ").last
+ end
+
private
def compute_duration(start)
@@ -8,8 +8,13 @@ def self.deliveries
Client.class_eval do
def fake_response
+ guid = UUID.new.generate
+
status = OpenStruct.new(status: 202)
- http = OpenStruct.new(response_header: status)
+ http = OpenStruct.new(
+ response_header: status,
+ response: "0: Accepted for delivery: #{guid}"
+ )
Response.new(http, Time.now)
end
View
@@ -1,5 +1,5 @@
module EventMachine
class Kannel
- VERSION = "0.1.0"
+ VERSION = "0.2.0"
end
end
@@ -2,7 +2,8 @@
describe EM::Kannel::Response do
let(:header) { mock(:header, status: "202") }
- let(:http) { mock(:http_client, response_header: header, response: "OK") }
+ let(:body) { "0: Accepted for delivery: 26ecfeea-6015-4025-bcae-0d0b71467d83" }
+ let(:http) { mock(:http_client, response_header: header, response: body) }
before do
now = Time.now
@@ -40,7 +41,14 @@
describe "#body" do
it "returns the body of the response" do
response = EM::Kannel::Response.new(http)
- response.body.should == "OK"
+ response.body.should == body
+ end
+ end
+
+ describe "#guid" do
+ it "returns the guid of the response" do
+ response = EM::Kannel::Response.new(http)
+ response.guid.should == "26ecfeea-6015-4025-bcae-0d0b71467d83"
end
end
end

0 comments on commit dd86a96

Please sign in to comment.