Skip to content

Commit

Permalink
Implemented tests and getting a message from an ID
Browse files Browse the repository at this point in the history
  • Loading branch information
gching committed May 13, 2014
1 parent 7c2d29b commit 9160881
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/wit_ruby/rest/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def send_sound_message(sound)

## GET - returns stored message for specific id.
## TODO - possibly renaming as it is ambigious compared to send_message.
## TODO - Notify Wit.ai as there documentation does not include the stats parameter
def get_message(message_id)

return @client.get("/messages/#{message_id}")
end

## GET - returns either a list of intents if no id is given.
Expand Down
20 changes: 20 additions & 0 deletions spec/wit_ruby/rest/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,24 @@
end


describe "Geting message info" do
let(:sent_message_result) {session.send_message(message)}
let(:sent_message_id) {sent_message_result.msg_id}
let(:resulting_message) {session.get_message(sent_message_id)}

before do
VCR.insert_cassette 'get_message', record: :new_episodes
end
after do
VCR.eject_cassette
end

it "should get back the same message and have the same has as the sent message results" do
expect(resulting_message.msg_id).to eql(sent_message_id)
expect(resulting_message.msg_body).to eql(sent_message_result.msg_body)
end

end


end

0 comments on commit 9160881

Please sign in to comment.