Skip to content

Instantly share code, notes, and snippets.

@t33chong
Created August 31, 2015 23:44
Show Gist options
  • Select an option

  • Save t33chong/b1f7bf41dd8da85c4b3e to your computer and use it in GitHub Desktop.

Select an option

Save t33chong/b1f7bf41dd8da85c4b3e to your computer and use it in GitHub Desktop.
lita http.post debugging
module Lita
module Handlers
class Temp < Handler
http.post '/foo/:bar', :foo
def foo(request, response)
bar = request.env['router.params'][:bar]
baz = request.params['baz']
response.write("#{bar}\n#{baz}")
end
end
Lita.register_handler(Temp)
end
end
require 'json'
require "spec_helper"
describe Lita::Handlers::Temp, lita_handler: true do
it { is_expected.to route_http(:post, '/foo/123').to(:foo) }
describe '#foo' do
it 'replies with the text contained in the baz field' do
params = { :baz => 'luhrmann' }.to_json
#params = { :baz => 'luhrmann' }
http_response = http.post(
'/foo/123',
params,
'Content-Type' => 'application/json'
)
#http_response = http.post('/foo/123?baz=luhrmann')
expect(http_response.body).to eq("123\nluhrmann")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment