Skip to content

Commit

Permalink
Merge pull request #1 from groupme/parse_guid_from_kannel_response
Browse files Browse the repository at this point in the history
Parse and set guid from kannel response
  • Loading branch information
cmdrkeene committed Jan 23, 2012
2 parents 306d4cc + dad7075 commit dd86a96
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
10 changes: 6 additions & 4 deletions Gemfile.lock
@@ -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)
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -60,7 +60,3 @@ list:
# Legal

See LICENSE for details

# TODO

* Parse Kannel responses
4 changes: 4 additions & 0 deletions lib/em-kannel/response.rb
Expand Up @@ -24,6 +24,10 @@ def error
@http.error
end

def guid
body.split(": ").last
end

private

def compute_duration(start)
Expand Down
7 changes: 6 additions & 1 deletion lib/em-kannel/test_helper.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/em-kannel/version.rb
@@ -1,5 +1,5 @@
module EventMachine
class Kannel
VERSION = "0.1.0"
VERSION = "0.2.0"
end
end
12 changes: 10 additions & 2 deletions spec/em-kannel/response_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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.